OAuth (recommended)
OAuth is the recommended method for interactive use. It opens your browser for secure authentication via OAuth 2.1 with PKCE.~/.config/affonso/auth.json. The CLI automatically refreshes expired tokens.
OAuth tokens are scoped to your account and automatically refreshed. You don’t need to manage API keys.
API key
For non-interactive use (scripts, CI/CD, AI agents), you can authenticate with an API key. There are three ways to provide it:- Per-command flag
- Environment variable
- Stored in config
Auth priority
When multiple methods are configured, the CLI uses this priority order:--api-keyflag (highest)AFFONSO_API_KEYenvironment variable- Stored config (
affonso config set api-key) - OAuth token (lowest)
API key formats
| Environment | Format |
|---|---|
| Production | sk_live_ + 32 characters |
| Development | sk_dev_ + 32 characters |
