Skip to content

fix(credentials): read Claude Code OAuth tokens from macOS Keychain#274

Open
airhorns wants to merge 1 commit intorivet-dev:mainfrom
airhorns:oauth-is-authed
Open

fix(credentials): read Claude Code OAuth tokens from macOS Keychain#274
airhorns wants to merge 1 commit intorivet-dev:mainfrom
airhorns:oauth-is-authed

Conversation

@airhorns
Copy link

Newer Claude Codes now store OAuth credentials in the macOS Keychain (service "Claude Code-credentials") instead of JSON files on disk. This adds a macOS-only fallback that reads from the Keychain via the security CLI when the file-based credential paths are not found.

For me locally, before this change, the claude agent reported creds=false, but now without changing my credentials at all, I get creds=true!

AIso, I know that there are sensitivities around using Claude code subscriptions from other apps, including the agents SDK, but for me I genuinely want this for personal use -- I just want a remote client for my claude code sessions that I am cooking up myself. So, I feel like my use of sandbox-agent to do this is very much within the loose Anthropic TOS guidance of "use an API key if you are building a business, otherwise its fine", but I understand if this is a wontfix.

Claude Code now stores OAuth credentials in the macOS Keychain (service "Claude Code-credentials") instead of JSON files on disk.
This adds a macOS-only fallback that reads from the Keychain via the `security` CLI when the file-based credential paths are not found.

Also refactors the OAuth JSON parsing into a shared helper that handles both RFC 3339 string and epoch-millis number expiry formats, matching the Keychain entry's numeric expiresAt field.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant