# ox login (/docs/cli/commands/auth)



ox login [#ox-login]

Authenticate your CLI with the SageOx platform using device flow authorization.

Usage [#usage]

<Terminal>
  <TerminalCommand>
    ox login
  </TerminalCommand>
</Terminal>

<Callout type="info">
  **For CI, cloud agents, or scripts:** use a Personal Access Token instead of interactive login. See [Personal Access Tokens](/docs/cli/pats).
</Callout>

How It Works [#how-it-works]

The `ox login` command uses OAuth 2.0 device flow:

1. **Request device code** - CLI requests a code from SageOx
2. **Open browser** - Authorization page opens automatically
3. **Authorize** - Sign in and approve CLI access
4. **Complete** - CLI receives and stores credentials

This is secure because your password never enters the terminal.

Credential Storage [#credential-storage]

| OS          | Location                            |
| ----------- | ----------------------------------- |
| macOS/Linux | `~/.config/sageox/credentials.json` |
| Windows     | `%APPDATA%\sageox\credentials.json` |

Commands [#commands]

<Terminal>
  <TerminalComment>
    Check authentication status
  </TerminalComment>

  <TerminalCommand>
    ox status
  </TerminalCommand>

  <TerminalComment>
    Remove stored credentials
  </TerminalComment>

  <TerminalCommand>
    ox logout
  </TerminalCommand>

  <TerminalComment>
    Re-authenticate (switch accounts)
  </TerminalComment>

  <TerminalCommand>
    ox login --force
  </TerminalCommand>
</Terminal>

Troubleshooting [#troubleshooting]

**Browser does not open** - Copy the displayed URL manually.

**Authentication timeout** - Device code expires after 15 minutes. Run `ox login` again.

**Wrong account** - Run `ox logout` then `ox login`.

Environment Variables [#environment-variables]

| Variable            | Description                                                          |
| ------------------- | -------------------------------------------------------------------- |
| `SAGEOX_API_URL`    | Override API endpoint                                                |
| `SAGEOX_NO_BROWSER` | Set to `1` to disable automatic browser                              |
| `SAGEOX_TOKEN`      | Personal Access Token for headless auth — see [pats](/docs/cli/pats) |

Related Commands [#related-commands]

* [Personal Access Tokens](/docs/cli/pats) - Headless auth for CI and cloud agents
* [Running ox in ephemeral environments](/docs/cli/ephemeral-mode) - Claude Code Cloud, Devin, GitHub Actions
* [ox doctor](/docs/cli/doctor) - Diagnose CLI issues
* [ox init](/docs/cli/init) - Initialize a repository
