# Authentication

> Authenticate Infa CLI with your Infa account using OAuth 2.1.

Source: https://infa.ai/docs/infa-cli-authentication

Authentication is required for connecting a board, syncing files with the cloud, and tracking Claude sessions in Supabase. Infa CLI uses **OAuth 2.1 with PKCE** — no API keys or passwords needed.

You don't need to sign in to try the CLI: signed out, `npx infa preview` opens your repo's docs on a local board at `infa.ai/local`, and nothing is uploaded. See [No account needed](https://infa.ai/docs/infa-cli-installation#no-account-needed).

## Sign in

```bash
infa auth
```

This opens a browser window to `infa.ai`. Log in with your Infa account (Google or email), approve access, and the CLI completes the flow automatically. You have **5 minutes** to complete the browser step. No account yet? Sign up free at [infa.ai/signup](https://infa.ai/signup), or use **Save to Infa** on the local board, which signs you up and connects the CLI to a free cloud board.

```
◆  Authentication
●  Starting OAuth flow
◇  Waiting for authentication
✓  Successfully authenticated
   User ID: 717f98f2-...
◆  You can now use `infa board` to select a board
```

## Check status

```bash
infa auth status
```

Shows whether you are currently authenticated and prints your User ID if so. Expired tokens are refreshed automatically before reporting status.

## Reset / sign out

```bash
infa auth reset
```

Clears the stored tokens from `.infa/config.yml`. The `clientId` is preserved so the next `infa auth` reuses the same OAuth client.

## How tokens are stored

After a successful login, credentials are saved to `.infa/config.yml` in your current working directory:

```yaml
auth:
  clientId: 9941cdcd-af9c-4040-959f-32e883d8043d
  accessToken: eyJ...
  refreshToken: ...
  expiresAt: "2026-04-20T12:00:00.000Z"
  tokenType: bearer
  scope: email profile
  userId: 717f98f2-...
boardId: b_3A4gbNTb
```

**Keep config.yml private** This file contains your access token. Add .infa/ to your .gitignore and never commit it.

## Token refresh

Tokens are refreshed automatically when they expire (with a 60-second skew). You do not need to re-run `infa auth` unless:

- You ran `infa auth reset`
- The refresh token itself has expired
- You switch Infa accounts

## Injecting tokens externally

When Infa CLI is launched by another process (such as the Electron app), tokens can be injected at startup via flags rather than reading from disk:

```bash
infa preview --token <access_token> --refresh-token <refresh_token>
```

Tokens injected this way are held in memory only — they are not written to `.infa/config.yml`.

Alternatively, any running server accepts tokens at any time via the API:

```bash
curl -X POST http://localhost:7100/api/auth/session \
  -H "Content-Type: application/json" \
  -d '{"accessToken": "...", "refreshToken": "..."}'
```

## Next steps

- [Connect a board](https://infa.ai/docs/infa-cli-connect-board)
- [CLI Reference](https://infa.ai/docs/infa-cli-reference)
