[BUG] /login reports "Login successful" but credentials are never written to macOS Keychain (v2.1.199)

Open 💬 1 comment Opened Jul 3, 2026 by inexo-studio

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)

  1. Keychain itself works fine — verified write/read/delete:

security add-generic-password / find-generic-password /
delete-generic-password with a test entry all succeed.

  1. 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.

  1. No file fallback exists: ~/.claude/.credentials.json does not exist.
  2. No conflicting env vars: ANTHROPIC_API_KEY and

CLAUDE_CODE_OAUTH_TOKEN are both unset; nothing related in
~/.zshrc / ~/.zprofile / ~/.zshenv.

  1. No apiKeyHelper or forceLoginMethod in settings.

settings.json only contains model/tui/theme options.

  1. Single installation confirmed: which -a claude

only /Users/<user>/.local/bin/claude. Reinstalled via
curl -fsSL https://claude.ai/install.sh | bash — no change.

  1. Keychain unlocked manually (security unlock-keychain) — no change.
  2. ~/.claude.json and ~/.claude are 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

  1. Start claude in any project
  2. Run /login, complete browser OAuth (subscription account)
  3. Terminal shows "Login successful"
  4. 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_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗