Skip to content

Fix macOS Keychain OAuth token retrieval#11

Merged
tylergraydev merged 1 commit into
mainfrom
fix/macos-keychain-oauth
Jan 1, 2026
Merged

Fix macOS Keychain OAuth token retrieval#11
tylergraydev merged 1 commit into
mainfrom
fix/macos-keychain-oauth

Conversation

@tylergraydev

Copy link
Copy Markdown
Owner

Summary

  • Fixes OAuth token retrieval on macOS by using the correct keychain service name (Claude Code-credentials instead of Claude Code)
  • Parses the JSON structure stored in keychain ({"claudeAiOauth":{"accessToken":"..."}}) instead of expecting a raw token
  • Adds fallback to raw token format for compatibility

Before: Status line showed -- -- for usage values on macOS
After: Status line correctly displays usage percentages (e.g., ◫ 16% (2h19m))

Test plan

  • Verified OAuth token is correctly retrieved from macOS Keychain
  • Added 6 new tests for macOS keychain retrieval scenarios
  • All 170 tests pass
  • Built and tested locally - status line now shows real usage data
  • Updated README to clarify macOS Keychain support

🤖 Generated with Claude Code

The OAuth token retrieval was failing on macOS because:
1. Wrong keychain service name - looked for "Claude Code" but Claude Code
   stores credentials under "Claude Code-credentials"
2. The keychain stores JSON with structure {"claudeAiOauth":{"accessToken":"..."}}
   rather than a raw token, so it needed to be parsed

This fix updates getOAuthTokenMacOS() to:
- Use the correct service name "Claude Code-credentials"
- Parse the JSON structure to extract claudeAiOauth.accessToken
- Fall back to raw token if the keychain returns a non-JSON value

Also adds 6 new tests for macOS keychain retrieval and updates README
to clarify macOS support.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@tylergraydev
tylergraydev merged commit af0855d into main Jan 1, 2026
3 checks passed
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