# ox login (https://sageox.ai/docs/cli/auth)

# ox login

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

## 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

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

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

## 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

**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

| 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

- [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
