Skip to main content

Login

amika auth login authenticates with Amika using the WorkOS Device Authorization Flow.

Quick start

# Log in (opens browser)
amika auth login

# Check login status
amika auth status

# Log out
amika auth logout

How it works

  1. The CLI requests a device code from WorkOS.
  2. A user code is displayed and the browser opens for you to authorize.
  3. The CLI polls WorkOS until you complete authorization.
  4. The session (access token, refresh token, email, org) is saved to ${XDG_STATE_HOME}/amika/workos-session.json.
  5. Access tokens are automatically refreshed when they are within 60 seconds of expiry.

Session storage

The session file is stored at ~/.local/state/amika/workos-session.json by default (following XDG Base Directory conventions). File permissions are set to 0600. The path can be overridden with the AMIKA_STATE_DIRECTORY environment variable.
CommandDescription
amika auth statusShow current login status (email and org)
amika auth logoutRemove the saved session

Environment variables

VariableDefaultDescription
AMIKA_API_URLhttps://app.amika.devOverride the remote API base URL. Used by sandbox commands when operating on remote sandboxes
AMIKA_WORKOS_CLIENT_IDOverride the default WorkOS client ID. If you change AMIKA_API_URL, you likely need to update this variable too

Credential discovery

amika auth extract discovers locally stored API credentials from multiple coding agent tools and prints them as shell environment assignments. You can use this to copy coding agent credentials into Amika’s web UI so you can spin up ready-to-go sandboxes from the web.

Quick start

# Print detected assignments
amika auth extract

# Export into current shell
eval "$(amika auth extract --export)"

# Skip OAuth sources
amika auth extract --no-oauth

Supported sources

Amika reads sources in priority order.
PrioritySourceFilesProviders
500Claude API key~/.claude.json.api, ~/.claude.jsonAnthropic
400Claude OAuth~/.claude/.credentials.json, ~/.claude-oauth-credentials.jsonAnthropic
300Codex~/.codex/auth.jsonOpenAI
290Amika env cache${XDG_CACHE_HOME}/amika/env-cache.jsonAny
280Amika keychain${XDG_DATA_HOME}/amika/keychain.jsonAny
270Amika OAuth${XDG_STATE_HOME}/amika/oauth.jsonAny
200OpenCode~/.local/share/opencode/auth.jsonAny
100Amp~/.amp/config.jsonAnthropic
Higher-priority sources win when multiple files provide the same provider key.

Output mapping

Amika normalizes provider names and exports common aliases:
  • Anthropic keys output as both ANTHROPIC_API_KEY and CLAUDE_API_KEY.
  • OpenAI keys output as both OPENAI_API_KEY and CODEX_API_KEY.
Example output:
ANTHROPIC_API_KEY='sk-ant-...'
CLAUDE_API_KEY='sk-ant-...'
OPENAI_API_KEY='sk-...'
CODEX_API_KEY='sk-...'

Provider canonicalization

Provider names are normalized before deduplication:
  • claude, anthropicanthropic
  • codex, openaiopenai
  • Other providers are lowercased, with separators normalized to hyphens

OAuth token handling

OAuth sources (claude_oauth, amika_oauth, Codex OAuth, OpenCode OAuth) are included by default. Use --no-oauth to skip them. OAuth tokens with an expiresAt or expires timestamp are skipped if expired.

Flags

FlagDefaultDescription
--exportfalsePrefix lines with export
--homedir <path>$HOMEOverride home directory for discovery
--no-oauthfalseSkip OAuth credential sources
Use --homedir in CI or test environments when you need deterministic credential fixtures.