fix: support hash-suffixed macOS Keychain service name#14
Closed
xicv wants to merge 3 commits into
Closed
Conversation
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 since the tool was reading stale tokens from the old entry. The fix dynamically discovers the correct keychain service name by searching for all matching entries and preferring the most specific (longest) one, with a fallback to the legacy name. Refactored getOAuthTokenMacOS into smaller focused functions: - findKeychainServiceName: discovers the correct service name - readKeychainContent: reads content from a given service - extractTokenFromKeychainContent: parses token from content
When the macOS Keychain entry doesn't exist (e.g., after re-authenticating in tmux/byobu), fall back to checking credential files (~/.claude/.credentials.json, etc.) matching the existing Linux behavior. Based on tylergraydev#15 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add two new block segment features: - timeDisplay option: show "remaining" (3h20m) or "absolute" (2:30pm) reset time - Sparkline history: visual usage trend (▁▂▃▄▅▆▇█) stored in ~/.claude/limitline-history.json Based on tylergraydev#9 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tylergraydev
added a commit
that referenced
this pull request
Feb 23, 2026
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.
3 tasks
Owner
|
Thanks for the contribution @xicv! The Keychain hash-suffix discovery was a great find. We've extracted just that fix into #16 (now merged), which includes your We closed this PR because it bundled three separate concerns into one:
Appreciate the effort — the core fix was solid! |
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.
Summary
Claude Code-credentials-697375ae) instead of the previousClaude Code-credentials401 Unauthorizederrors when fetching usage data, since the tool was reading stale tokens from the old keychain entryChanges
Refactored
getOAuthTokenMacOS()insrc/utils/oauth.tsinto smaller focused functions:findKeychainServiceName()— searches the keychain for allClaude Code-credentials*entries and returns the longest match (the one with the hash suffix)readKeychainContent()— reads and returns content from a given keychain serviceextractTokenFromKeychainContent()— parses the OAuth token from keychain JSON contentFalls back to the legacy
Claude Code-credentialsname if the suffixed entry fails, so it remains backwards-compatible.Test plan
Claude Code-credentials) and new (Claude Code-credentials-697375ae) keychain entries present401 Unauthorized