Skip to main content

get_token

Function get_token 

Source
pub fn get_token() -> Result<String, CredentialError>
Expand description

Retrieve the OAuth access token from platform-specific storage.

On macOS, this reads from the Keychain. On Linux, this reads from ~/.claude/.credentials.json.

The environment variable CLAUDE_CODE_OAUTH_TOKEN takes precedence on all platforms if set.

ยงErrors

Returns CredentialError if:

  • Credentials are not found
  • Credentials are expired
  • Credentials cannot be parsed
  • Required fields are missing