Skip to content

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

Description

@inexo-studio

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • 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.
  2. 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.
  3. No file fallback exists: ~/.claude/.credentials.json does not exist.
  4. No conflicting env vars: ANTHROPIC_API_KEY and
    CLAUDE_CODE_OAUTH_TOKEN are both unset; nothing related in
    ~/.zshrc / ~/.zprofile / ~/.zshenv.
  5. No apiKeyHelper or forceLoginMethod in settings.
    settings.json only contains model/tui/theme options.
  6. Single installation confirmed: which -a claude →
    only /Users//.local/bin/claude. Reinstalled via
    curl -fsSL https://claude.ai/install.sh | bash — no change.
  7. Keychain unlocked manually (security unlock-keychain) — no change.
  8. ~/.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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:authbugSomething isn't workingplatform:macosIssue specifically occurs on macOSstaleIssue is inactive

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions