Skip to content

fix: support hash-suffixed macOS Keychain service name#16

Merged
tylergraydev merged 1 commit into
mainfrom
fix/macos-keychain-hash-suffix
Feb 23, 2026
Merged

fix: support hash-suffixed macOS Keychain service name#16
tylergraydev merged 1 commit into
mainfrom
fix/macos-keychain-hash-suffix

Conversation

@tylergraydev

Copy link
Copy Markdown
Owner

Summary

  • Claude Code now stores credentials under a hash-suffixed Keychain service name (e.g. Claude Code-credentials-697375ae) instead of the legacy Claude Code-credentials
  • This caused 401 Unauthorized errors when fetching usage data, since the tool was reading stale tokens from the old entry
  • Dynamically discovers the correct service name by searching for all matching Keychain entries and preferring the most specific (longest) match, with fallback to the legacy name

Based on the approach from #14 by @xicv — extracted as a focused single-concern fix without the unrelated feature additions.

Changes

  • findKeychainServiceName() — searches the Keychain for all Claude Code-credentials* entries and returns the longest match
  • extractTokenFromKeychainContent() — shared helper for parsing OAuth tokens from Keychain content
  • getOAuthTokenMacOS() — now tries the discovered service name first, then falls back to the legacy name

Test plan

  • All 184 existing tests pass
  • TypeScript compiles cleanly
  • Backwards-compatible: falls back to legacy Claude Code-credentials if no suffixed entry exists

Claude Code now stores credentials under a hash-suffixed keychain
service name (e.g. "Claude Code-credentials-697375ae") instead of
the previous "Claude Code-credentials". This caused 401 Unauthorized
errors when fetching usage data.

Dynamically discovers the correct keychain service name by searching
for all matching entries and preferring the most specific (longest)
match, with a fallback to the legacy name.

Based on the approach from #14 by @xicv.
@tylergraydev
tylergraydev merged commit 728341b into main Feb 23, 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