Skip to main content
The Affonso CLI supports two authentication methods. You can use either one depending on your use case. OAuth is the recommended method for interactive use. It opens your browser for secure authentication via OAuth 2.1 with PKCE.
After authenticating, tokens are stored locally in ~/.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:
Never commit API keys to version control or share them publicly. Use environment variables in CI/CD pipelines.

Auth priority

When multiple methods are configured, the CLI uses this priority order:
  1. --api-key flag (highest)
  2. AFFONSO_API_KEY environment variable
  3. Stored config (affonso config set api-key)
  4. OAuth token (lowest)

API key formats

You can create API keys in your Affonso dashboard.