[BUG] /login reports "Login successful" but credentials are never written to macOS Keychain (v2.1.199)
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Environment
- Claude Code version: 2.1.199 (native installer, single installation at ~/.local/bin/claude)
- OS: macOS (MacBook Pro)
- Terminal: Terminal.app (local GUI session, no SSH, no tmux)
- Auth method: Claude subscription (Pro/Max), NOT API key
Bug Description
Running /login completes the OAuth flow in the browser and shows
"Login successful", but immediately after, Claude Code shows
"Not logged in · Please run /login". The credentials are never
persisted — the login loop repeats indefinitely (tried ~20 times).
What I ruled out (diagnostics)
- Keychain itself works fine — verified write/read/delete:
security add-generic-password / find-generic-password /
delete-generic-password with a test entry all succeed.
- The credential entry is NEVER created:
security find-generic-password -s "Claude Code-credentials" -a "$USER" -w
→ "The specified item could not be found in the keychain."
security dump-keychain | grep -i claude only shows
"Claude Safe Storage" (Claude Desktop app), no CLI entry at all.
- No file fallback exists:
~/.claude/.credentials.jsondoes not exist. - No conflicting env vars:
ANTHROPIC_API_KEYand
CLAUDE_CODE_OAUTH_TOKEN are both unset; nothing related in
~/.zshrc / ~/.zprofile / ~/.zshenv.
- No
apiKeyHelperorforceLoginMethodin settings.
settings.json only contains model/tui/theme options.
- Single installation confirmed:
which -a claude→
only /Users/<user>/.local/bin/claude. Reinstalled via
curl -fsSL https://claude.ai/install.sh | bash — no change.
- Keychain unlocked manually (
security unlock-keychain) — no change. ~/.claude.jsonand~/.claudeare owned by my user with
correct permissions. ~/.claude.json does contain an
"oauthAccount" key, so account info is written, but the token is not.
Workaround
claude setup-token + CLAUDE_CODE_OAUTH_TOKEN env var works,
confirming the OAuth flow itself is fine — only credential
persistence is broken.
What Should Happen?
Expected Behavior
After a successful OAuth login, the token should be written to the
macOS Keychain ("Claude Code-credentials") or to
~/.claude/.credentials.json, and the session should stay authenticated.
Actual Behavior
"Login successful" is displayed, but no credential is written anywhere
(neither Keychain nor file), so authentication is lost instantly.
Error Messages/Logs
Steps to Reproduce
Steps to Reproduce
- Start
claudein any project - Run
/login, complete browser OAuth (subscription account) - Terminal shows "Login successful"
- Next screen immediately shows "Not logged in · Please run /login"
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.199
Platform
Other
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗