VSCode extension: repeated login loop caused by corrupted Keychain credentials (empty accessToken/refreshToken)
Environment
- macOS Darwin 25.6.0 (arm64)
- VSCode extension: anthropic.claude-code v2.1.220-darwin-arm64
- Browser used for OAuth: Microsoft Edge
Bug
The VSCode extension repeatedly prompts to sign in ("login loop") even after
completing the OAuth flow successfully in the browser.
Root cause found
The macOS Keychain entry "Claude Code-credentials" contained:
{"claudeAiOauth":{"accessToken":"","refreshToken":"","expiresAt":0,
"refreshTokenExpiresAt":<valid future timestamp>, ...}}
accessToken and refreshToken were empty strings, while refreshTokenExpiresAt
held a valid value — indicating OAuth had completed at some point, but the
extension failed to persist the actual token strings back to Keychain.
Extension log confirmed:
[ERROR] Failed to check metrics opt-out status: Auth error: No API key available
Repro steps
- Click "Sign in" in the Claude Code VSCode extension.
- Complete the OAuth authorize flow in the browser.
- Extension continues to show signed-out / re-prompts to sign in.
- Inspect Keychain:
security find-generic-password -s "Claude Code-credentials" -w
→ accessToken/refreshToken are empty strings.
Deleting the Keychain entry and retrying does not reliably resolve it —
the OAuth authorize page also sometimes shows "Sign in again to continue"
(recent sign-in required for scope org:create_api_key) despite an already
active claude.ai session in the same browser, suggesting the token exchange
step after re-auth is not completing/persisting correctly.
Expected
After a successful OAuth authorization, valid access/refresh tokens should
be written to Keychain and the extension should recognize the signed-in state.