-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Claude "Avoid Keychain prompts": account switch leaves ~/.claude/.credentials.json missing → "OAuth credentials not found" while Keychain token is valid #1975
Copy link
Copy link
Closed
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerThis issue is about auth, provider routing, model choice, or SecretRef resolution.This issue is about auth, provider routing, model choice, or SecretRef resolution.impact:securityThis issue is about security boundaries, credentials, authz, sandboxing, or sensitive data.This issue is about security boundaries, credentials, authz, sandboxing, or sensitive data.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.User-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Metadata
Metadata
Assignees
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:auth-providerThis issue is about auth, provider routing, model choice, or SecretRef resolution.This issue is about auth, provider routing, model choice, or SecretRef resolution.impact:securityThis issue is about security boundaries, credentials, authz, sandboxing, or sensitive data.This issue is about security boundaries, credentials, authz, sandboxing, or sensitive data.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.User-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
TL;DR: With "Avoid Keychain prompts" enabled (
debugDisableKeychainAccess = true), CodexBar reads Claude OAuth from the plaintext~/.claude/.credentials.jsoninstead of the Keychain. But after switching Claude accounts, Claude Code sometimes writes the new token only to the Keychain and not to~/.claude/.credentials.json— the file goes missing entirely. CodexBar then shows "Claude OAuth credentials not found. Runclaudeto authenticate." even though a valid, non-expired token with the right scopes is sitting in the Keychain.Every existing keychain/credentials issue I found is about the Keychain item being wrong or absent (#1844, #1823, #1161). This one is the opposite: the Keychain is fine; the file the avoid-keychain path depends on is the thing that disappears on account switch.
Environment
defaults read com.steipete.codexbar debugDisableKeychainAccess→1)Repro
source=credentialsFile). Confirm usage loads./loginas a different account).claudeto authenticate."Smoking gun
At the point of failure:
So the Keychain has a healthy
claudeAiOauthtoken; the plaintext file simply does not exist. Because keychain access is disabled, CodexBar has nothing to read and fails closed with "credentials not found."codexbar usage --provider claude -vafter recreating the file confirms the same token reads fine:Manual recovery (workaround)
Regenerate the file from the Keychain, then Refresh (⌘R):
Suggested fix
When Avoid Keychain prompts is enabled and
~/.claude/.credentials.jsonis missing/unreadable, fall back to a non-interactive Keychain read (the Security.framework no-UI policy from #1877) before surfacing "credentials not found" — i.e. read-only, never prompting. That would make the avoid-keychain path resilient to Claude Code writing the token to only one of the two stores after an account switch, without reintroducing prompts.(Reported via a debugging session; happy to grab additional logs.)