# Authentication

Source: https://projectfeed.app/docs/cli/configuration/authentication

Sign in interactively or provide credentials for unattended CLI runs.

## Sign in

Sign in with a personal API token or a workspace API key. Interactive login stores the key in the local config file for the selected profile or workspace override.

A workspace key is tied to one workspace. A personal token works across your workspaces, so workspace commands also need a workspace target: `--workspace <slug>`, the `PROJECT_FEED_WORKSPACE` environment variable, `pf link`, or `pf config set defaultWorkspace <slug>`.

 `pf auth login` Validate and store a personal API token or workspace API key in the selected profile or workspace override. A personal token still needs a workspace target for workspace commands.

Options

-   `--web` boolean
    
    Sign in through your browser instead of pasting a key. pf prints a code and opens the approval page, where you choose one workspace. The stored key has full API access there, limited by your role, can read and update your account profile and list your personal API tokens, and renews itself for 30 days, after which you sign in again.
    
-   `--with-token` boolean
    
    Read the key from standard input. Use it in scripts and CI so the key stays out of shell history and process listings.
    
-   `--token` string
    
    Provide the key as an argument. The key then appears in shell history and process listings, so pf prints a warning. Prefer --with-token, the prompt, or PROJECT_FEED_API_KEY.
    
-   `--workspace` string
    
    Store the key for one workspace override
    

Example

Shell

```
pf auth login
pf auth login --web
pf auth login --workspace studio
echo "$PF_KEY" | pf auth login --with-token
```

 `pf auth logout` Remove stored credentials. Without --workspace it removes the profile key and every workspace key, with any renewal data for browser sign-ins. With --workspace it removes only that workspace's. Environment variables are not touched.

Options

-   `--workspace` string
    
    Remove the key from one workspace override
    
-   `--confirm` boolean
    
    Skip the confirmation prompt. Required when there is no terminal or --no-input is set; without it the command exits with code 2.
    

Example

Shell

```
pf auth logout
pf auth logout --workspace studio --confirm
```

 `pf auth revoke` Revoke the API key in use on the server, then remove it from the profile. Requests that use it return 401 afterwards. A key from --api-key or PROJECT_FEED_API_KEY is revoked but stays wherever you set it.

Options

-   `--confirm` boolean
    
    Skip the confirmation prompt
    
-   `--dry-run` boolean
    
    Preview without making changes
    

Example

Shell

```
pf auth revoke --dry-run
pf auth revoke --confirm
```

 `pf auth status` Show current authentication status. It exits with code 1 when no key is configured.

Options

-   `--workspace` string
    
    Inspect the key selected for one workspace override
    
-   `--check` boolean
    
    Also verify the key against Project Feed
    

Example

Shell

```
pf auth status
pf auth status --check
pf auth status --profile work --workspace studio
```

 `pf auth token` Print the API key in use so another tool can read it. Treat the output as a secret.

Options

-   `--workspace` string
    
    Print the key for one workspace override
    

Example

Shell

```
pf auth token
curl -H "Authorization: Bearer $(pf auth token)" https://projectfeed.app/api/v1/auth/check
```

 `pf auth check` Validate the selected key against Project Feed and show its source, user ID, scope, audience, expiration, effective permissions, workspace, and API version.

Example

Shell

```
pf auth check
pf auth check --json
```

## Authenticate safely

1.  1.
    
    ### Create a credential
    
    Create a personal API token for your own terminal use or a service account for unattended automation. Grant only the required scopes.
    
2.  2.
    
    ### Sign in
    
    Run `pf auth login --web` to approve the sign-in in your browser, or `pf auth login` to paste a key. In automation, provide PROJECT_FEED_API_KEY through a protected secret, or pipe the key to `pf auth login --with-token`, rather than passing it as an argument.
    
3.  3.
    
    ### Check the credential
    
    Run `pf auth status` to inspect the credential source, then `pf auth check` to verify its effective access against the server.
    
4.  4.
    
    ### Run a read-only command
    
    Run one read-only command in the intended workspace before making a change.
    

Credential precedence is `--api-key`, PROJECT_FEED_API_KEY from the process or local .env file, then the workspace or profile key in the config file. An environment value can override a key stored in a profile selected with `--profile`.

## Fix sign-in problems

The wrong key is selected

Run pf auth status and pf config get apiKey --source. Remove or change PROJECT_FEED_API_KEY when it shadows the intended profile, then run pf auth check again.

A personal token reports a missing workspace

Pass --workspace <slug> or set PROJECT_FEED_WORKSPACE, or set defaultWorkspace in the profile. Run pf workspace list to find the slug.

## Next steps

-   [Manage personal API tokens](https://projectfeed.app/docs/account/api-tokens)
-   [Use service accounts in automation](https://projectfeed.app/docs/api/service-accounts/overview)
-   [Read the API authentication contract](https://projectfeed.app/docs/api/authentication)
