fix(credentials): read Claude Code OAuth tokens from macOS Keychain#274
Open
airhorns wants to merge 1 commit intorivet-dev:mainfrom
Open
fix(credentials): read Claude Code OAuth tokens from macOS Keychain#274airhorns wants to merge 1 commit intorivet-dev:mainfrom
airhorns wants to merge 1 commit intorivet-dev:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
securityCLI when the file-based credential paths are not found.For me locally, before this change, the
claudeagent reportedcreds=false, but now without changing my credentials at all, I getcreds=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.