# Sign in and profiles

> Connect the Corfedo CLI to a workspace with browser sign-in or an API key file, and switch between saved profiles.

Source: https://docs.corfedo.ai/connect/cli/sign-in-and-profiles/

A CLI profile is a named connection to one workspace. It holds the workspace address and how to sign in, never a password or token. Commands use the default profile unless you pass `--profile NAME`.

## Sign in with your browser

```sh
corfedo auth login --api https://corfedo.example.com/
```

The CLI opens your browser and prints the sign-in link. Sign in, choose which repositories the CLI may read and select **Allow**. [Approve access](https://docs.corfedo.ai/connect/mcp/clients/#approve-access) explains the repository choice.

The CLI asks for every [permission](https://docs.corfedo.ai/connect/authentication/#permissions). Under **Permissions** each one is a checked box. Clear any you do not want the CLI to have.

To sign in to a second workspace, name its profile:

```sh
corfedo auth login --api https://corfedo.example.com/ --profile work
```

The CLI keeps credentials in the macOS Keychain or the Linux desktop keyring, or else in files only your user can read under `~/.config/corfedo`. It renews them while you work.

### Sign in on a machine without a browser

On Linux without a desktop, for example over SSH, the CLI only prints the link.

1. Open the link in a browser on any computer and sign in.
2. The browser goes to a `http://localhost:…/corfedo/callback` page that does not load. Copy its address and paste it into the CLI after `Address:`.

If you forward that port over SSH instead, sign-in finishes without pasting.

### Check the result

```sh
corfedo connection show
```

**Check:** it prints the connection's workspace, client, expiry and repositories.

## Use an API key file

API keys suit CI, scripts and services that run without a person.

1. In your workspace, open **Connect** › **Manage connections** and select **Create API key**.
2. Create the key and select **Download key file**. This is the only time you can download it.
3. Store the file where only you can read it, then configure a profile with its absolute path:

```sh
chmod 600 /home/me/.config/corfedo-ci.json
corfedo auth configure-api-key --key-file /home/me/.config/corfedo-ci.json --profile ci
corfedo connection show --profile ci
```

The workspace address comes from the key file. The file must be a regular file, not a symbolic link, and not readable by group or others. The key keeps the [permissions](https://docs.corfedo.ai/connect/authentication/#api-keys) chosen when it was created.

## Switch and manage profiles

`corfedo profile list` lists profiles and marks the default. `corfedo profile use NAME` changes the default, and `--profile NAME` picks a profile for one command. [CLI commands](https://docs.corfedo.ai/reference/cli/#set-up-and-profiles) lists the other profile and `auth` commands.

To sign in again to an existing profile, for example to change its permissions, pass `--replace` with the same workspace address:

```sh
corfedo auth login --api https://corfedo.example.com/ --profile work --replace
```

## Remove access

For a browser sign-in, `corfedo auth logout` deletes the credentials on this machine. `corfedo profile remove NAME --local-only --yes` forgets any profile, also an API key profile. Neither revokes access. To revoke access, open **Connect** › **Manage connections** and select **Revoke** for the signed-in client or API key.

## Troubleshooting

| Message | Fix |
| --- | --- |
| `credential_store_unavailable` | The profile's keyring is locked, for example over SSH. Sign in to the desktop to unlock it, or sign in again with `--replace`. |
| `That address does not finish this sign-in` | Paste the whole address from the same sign-in, starting with `http://localhost`. If the sign-in took longer than five minutes, run `auth login` again. |
| `profile_required` | Pass `--profile NAME`, or set a default with `corfedo profile use NAME`. |
| `authentication_required` or `reauthorization_required` | Sign in again with `--replace`. |
| `missing_scope` | The connection lacks a permission the command needs. The message names it. Sign in again with `--replace` and keep it checked. |
| `profile_exists` | Add `--replace` to sign in again to that profile. |
| `workspace_moved` (a warning) | The workspace has a new address, and the old one still works. Sign in again with the new address. |
| Browser sign-in fails before you can sign in | The installation may not reach `https://clients.corfedo.ai/cli.json`, which describes the CLI. Ask whoever runs Corfedo to allow HTTPS to it. |

## Related

- [Search and read](https://docs.corfedo.ai/connect/cli/search-and-read/) is the next step. [Scripting](https://docs.corfedo.ai/connect/cli/scripting/) covers API keys in CI.
