ClaudeCodeSDK.Auth.Providers.Anthropic (claude_code_sdk v0.2.2)
View SourceAnthropic-specific authentication via claude setup-token.
Summary
Functions
Returns the environment variable name for Claude OAuth tokens.
Executes claude setup-token and extracts the OAuth token.
Functions
@spec oauth_env_var() :: String.t()
Returns the environment variable name for Claude OAuth tokens.
Examples
iex> ClaudeCodeSDK.Auth.Providers.Anthropic.oauth_env_var()
"CLAUDE_CODE_OAUTH_TOKEN"
@spec setup_token() :: {:ok, String.t(), DateTime.t()} | {:error, term()}
Executes claude setup-token and extracts the OAuth token.
This requires:
- Claude Code CLI installed (v2.0.10+)
- Active Claude subscription
- Interactive terminal for OAuth flow
Process
- Opens browser to claude.ai/oauth/authorize
- User signs in with Claude account
- CLI displays OAuth token (sk-ant-oat01-...)
- Token is valid for 1 year
Token Format
Returns OAuth token: sk-ant-oat01-... Should be set as: export CLAUDE_CODE_OAUTH_TOKEN=<token>