[BUG] macOS 26: /login completes ("Login successful") but token never written to Keychain — browser does not auto-open, device code flow used instead

Status Open
Reported on v2.1.185
Maintainer reply None cached
Activity 6 comments · opened Jun 22, 2026

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?

On macOS 26.4 (Apple Silicon), /login completes the OAuth flow and shows
"Login successful", but the authentication token is never persisted to the
macOS Keychain. As a result, even in the same session immediately after
"Login successful", any message returns "Not logged in · Please run /login".

Two additional symptoms are present:

  1. The browser does not auto-open during /login (even though open <url>

works fine from the same shell). Claude Code falls back to displaying the
URL manually and using the device code flow (manual code paste).

  1. claude doctor consistently reports "macOS Keychain is not writable",

even after deleting the existing Keychain entry and even after
pre-creating a "Claude Code-credentials" entry with the -A flag
(allow all applications).

What Should Happen?

After completing /login (either via browser redirect or device code flow),
the authentication token should be persisted to the macOS Keychain so that
subsequent sessions do not require re-authentication.

The browser should also auto-open during /login when a default browser is
configured and open <url> works from the shell.

Error Messages/Logs

claude doctor output:
  Installation warnings ⚠
  ├ macOS Keychain is not writable. Console login will fail to save
    your API key.
  └ Run: security unlock-keychain ~/Library/Keychains/login.keychain-db

/status output (immediately after "Login successful"):
  Auth token: none

After /login:
  security find-generic-password -a "$(whoami)" -s "Claude Code-credentials" -w
  → security: SecKeychainSearchCopyNext: The specified item could not be
    found in the keychain.

Steps to Reproduce

  1. Install Claude Code via native installer on macOS 26.4 (Apple Silicon):

curl -fsSL https://claude.ai/install.sh | bash

  1. Run: claude
  1. Run /login inside Claude Code
  1. Note: browser does NOT auto-open. URL is displayed in terminal.

Claude Code falls back to device code flow.

  1. Manually open URL in browser (Arc or Safari — tested both).

Browser shows "認証コード / Authentication Code" page with a manual code.

  1. Paste the code into Claude Code when prompted → "Login successful" appears
  1. Immediately run /status → Auth token: none
  1. Type any message → "Not logged in · Please run /login"
  1. Confirm Keychain was not written:

security find-generic-password -a "$(whoami)" -s "Claude Code-credentials" -w
→ item could not be found

Additional diagnostic steps performed:

  • security unlock-keychain ~/Library/Keychains/login.keychain-db → no effect
  • Deleted existing Keychain entry, re-ran /login → same result
  • Pre-created entry with -A flag (allow all apps):

security add-generic-password -a "$(whoami)" \
-s "Claude Code-credentials" -w '{"placeholder":"placeholder"}' -A
→ after /login, entry still shows placeholder (not updated by Claude Code)

  • security add-generic-password with a test service name → SUCCESS

(Keychain is writable from CLI)

  • xattr -l $(which claude) → no quarantine attribute
  • open "https://claude.ai" → browser opens correctly
  • sw_vers → ProductVersion: 26.4

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

Unknown — last known working around 2026-05-09 based on a Keychain entry timestamp. Exact version not recorded.

Claude Code Version

2.1.185

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Workaround currently in use:
claude setup-token → export CLAUDE_CODE_OAUTH_TOKEN=<token>
This works but provides user:inference scope only (user:profile missing).

Reproduced in both Terminal.app (macOS) and VS Code integrated terminal.

Related issue: #48162 (similar "macOS Keychain is not writable" symptom
caused by missing -U flag on add-generic-password). However, this issue
differs in that the token is not written even when no Keychain entry exists,
and even when a pre-created entry with -A (allow all apps) is present:

# Pre-created entry to rule out ACL as the cause:
security delete-generic-password -a "$(whoami)" -s "Claude Code-credentials"
security add-generic-password -a "$(whoami)" -s "Claude Code-credentials" \
-w '{"placeholder":"placeholder"}' -A
# After /login → "Login successful", entry still shows placeholder.
# Claude Code did not update it.

Keychain writability confirmed from CLI (different service name works):
security add-generic-password -a "$(whoami)" -s "test-write" -w "testvalue"
→ SUCCESS

Browser auto-open:
open "https://claude.ai" works from shell, but claude binary does not
trigger browser open during /login. Falls back to device code flow
(manual code paste in terminal). This behavior is consistent across
Terminal.app and VS Code integrated terminal.

After pasting the device code and seeing "Login successful":

  • /status shows: Auth token: none
  • Sending any message returns: Not logged in · Please run /login
  • security find-generic-password → item could not be found

codesign output on binary:
codesign -v ~/.local/share/claude/versions/2.1.185 --deep
→ "the code is valid but does not seem to be an app"

No quarantine attribute on binary:
xattr -l $(which claude) → (no output)

Hypothesis: macOS 26 may be restricting Keychain write access and/or
URL-open capabilities for native binaries in ~/.local/share/ that are
not packaged as .app bundles. Both failures (browser not opening,
Keychain not writable) may share the same root cause related to macOS 26
security policy changes for non-app-bundle binaries.

View original on GitHub ↗

6 Comments

github-actions[bot] · 3 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/63919
  2. https://github.com/anthropics/claude-code/issues/65466
  3. https://github.com/anthropics/claude-code/issues/44585

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

rindo-610 · 3 months ago

This issue is NOT a duplicate of #44585 (Windows-specific).

#63919 and #65466 share similar symptoms, but this issue includes
macOS 26-specific diagnostics that may help identify the root cause:

  • Browser does not auto-open during /login (open command works from shell)
  • Keychain write fails even when entry is pre-created with -A flag
  • codesign shows "code is valid but does not seem to be an app"
  • Workaround: CLAUDE_CODE_OAUTH_TOKEN via claude setup-token

These additional symptoms suggest macOS 26 may be applying new security
restrictions to native binaries in ~/.local/share/ that are not .app bundles.

4dlt · 3 months ago

Run into the same problem (running the same version of claude code). Found a bypass but no way to actually fix the core issue.

Also, started to happen for me after my mac auto updated to version Tahoe 26.5.1 (25F80)

Run these in your terminal:

  1. Generate the token (opens your browser; after approving, it PRINTS a token starting with sk-ant-oat...)

claude setup-token
Copy the printed token, then:

  1. Store it in ~/.zshrc (paste when prompted — input is hidden, won't hit shell history)

read -rs "?Paste token then Enter: " TOK && print -r -- "export CLAUDE_CODE_OAUTH_TOKEN=\"$TOK\"" >> ~/.zshrc && unset TOK

  1. Reload and verify

exec zsh
claude --version && echo "token set: ${CLAUDE_CODE_OAUTH_TOKEN:+yes}"

silasg · 3 months ago

I have the same problem. Unfortunately the workaround seem not to work for me, I stell get

Please run /login · API Error: 401 Invalid bearer token

Tried several times, also adding the Token manually to env.

bashfulrobot · 2 months ago

I just got a Mac, running latest as of today. Same issues. Adding in hopes of keeping this one open as it is the most identical to what I see compared to the other proposed duplicates.

gharibe · 1 month ago

This is not the same issue as 63919. but it seems the 63919 is closed. I'm on Tahoe 26.6.2

Found 3 possible duplicate issues: 1. [[BUG] Login succeeds but every request immediately returns "Not logged in" (macOS, OAuth) #63919](https://github.com/anthropics/claude-code/issues/63919) 2. [[BUG] claude auth login succeeds but OAuth token not readable in new sessions (macOS, native binary install) #65466](https://github.com/anthropics/claude-code/issues/65466) 3. /login shows "Login successful" but immediately reverts to "Not logged in" #44585 This issue will be automatically closed as a duplicate in 3 days. If your issue is a duplicate, please close it and 👍 the existing issue instead To prevent auto-closure, add a comment or 👎 this comment 🤖 Generated with Claude Code

This is not the same issue as 63919. but it seems the 63919 is closed. I'm on Tahoe 26.6.2

The [keychain] readAsync failed; not caching a null line
It persists after a full reboot
The Keychain entry itself exists and looks normal (ruling out a missing-credential explanation)
Claude Code version (2.1.236) and install method (Homebrew cask)