Skip to content

feat(providers): cache Claude Code sign-in in memory - #11

Merged
DerRafDev merged 1 commit into
mainfrom
feat/claude-credential-cache
Oct 27, 2026
Merged

DerRafDev merged 1 commit into
mainfrom
feat/claude-credential-cache

Conversation

@DerRafDev

@DerRafDev DerRafDev commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Reading Claude Code's Keychain item on every refresh could show the macOS permission prompt each time on builds without "Always Allow".

ClaudeCredentialCache keeps the token in memory while TokenBar runs. Each refresh reads only the item's modification date (attributes, no prompt); the data is read again only when the item changed, or when the token expired or was rejected, at most once every 15 minutes.

  • 401, or 403 "OAuth token has been revoked" (as Claude Code does), drops the token and it is never sent again; other 403s keep it.
  • Tokens within 60 s of expiresAt count as expired.
  • Sign-out clears the cache; access denied is never cached, so a manual refresh can still ask again.
  • Nothing is written to disk, UserDefaults, or another Keychain item.

Checklist

  • scripts/lint.sh and scripts/test.sh pass locally
  • No tokens, cookies, account IDs, or real responses in code, fixtures, or logs
  • Docs updated if behavior or architecture changed

Reading Claude Code's Keychain item on every refresh could show the
macOS permission prompt each time on builds without "Always Allow".

ClaudeCredentialCache keeps the token in memory while TokenBar runs.
Each refresh reads only the item's modification date (attributes, no
prompt); the data is read again only when the item changed, or when
the token expired or was rejected, at most once every 15 minutes.

- 401, or 403 "OAuth token has been revoked" (as Claude Code does),
  drops the token and it is never sent again; other 403s keep it.
- Tokens within 60 s of expiresAt count as expired.
- Sign-out clears the cache; access denied is never cached, so a
  manual refresh can still ask again.
- Nothing is written to disk, UserDefaults, or another Keychain item.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying tokenbar with  Cloudflare Pages  Cloudflare Pages

Latest commit: 57af2cd
Status: ✅  Deploy successful!
Preview URL: https://2598946d.tokenbar-2vf.pages.dev
Branch Preview URL: https://feat-claude-credential-cache.tokenbar-2vf.pages.dev

View logs

@DerRafDev
DerRafDev merged commit 7ef194b into main Oct 27, 2026
4 checks passed
@DerRafDev
DerRafDev deleted the feat/claude-credential-cache branch November 6, 2026 21:52
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