[BUG] Login succeeds but every request immediately returns "Not logged in" (macOS, OAuth)
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?
After running /login, Claude Code reports "Login successful" and the welcome banner shows my correct name and organization. But the very next request — even just typing "hi" — immediately returns "Not logged in · Please run /login". The credential does not survive past the login step.
Some sessions a fresh login works for a few hours and then drops on its own; today it fails immediately after every successful login. Re-logging in does not help.
The credentials file is never written: cat ~/.claude/.credentials.json returns no file even right after a successful login, and no refreshToken is persisted (appears related to #37402). The Keychain entry "Claude Code-credentials" IS present after login, but requests still fail.
Already ruled out: no ANTHROPIC_API_KEY / ANTHROPIC_BASE_URL in env; clean global and project settings.json; Keychain credential deleted and recreated; same failure on two separate networks (home + office WiFi); system clock synced; updated 2.1.156 → 2.1.158 with no change.
What Should Happen?
After a successful login ("Login successful" + correct name/org shown), Claude Code should stay authenticated and process the requests that follow. The OAuth token should persist and auto-refresh in the background, so I should not have to re-login repeatedly — and never see "Not logged in" immediately after a login that just succeeded.
Error Messages/Logs
Not logged in · Please run /login
That's the only error the UI shows. If the form lets you add more detail, include these supporting observations underneath it:
- /login itself reports: "Login successful" (no error)
- Welcome banner shows correct name + org, so auth partially succeeds
- cat ~/.claude/.credentials.json → no file, even immediately after successful login
- security find-generic-password -s "Claude Code-credentials" → entry IS present in login.keychain-db
- env | grep -i anthropic → empty
If you can grab a real debug log, it'll strengthen the report a lot. In a plain terminal (the prompt ending in %, not inside Claude Code), run:
claude --debug
Then send one prompt like hi. It'll print verbose output including the auth/token step and likely the underlying API error (often a 401 with a token-expired or refresh-failure message). Copy whatever it prints around the failure and paste that into the logs field too — but remove anything that looks like a token or key (long strings, sk-ant-..., eyJ...) before pasting, since logs can contain credentials.
If claude --debug doesn't produce anything useful or you'd rather not run it, just the Not logged in · Please run /login line plus the bullet observations above is enough to file. Want me to keep going if there's another field after this one?Opus 4.8 High
Steps to Reproduce
- Run
claude loginin the terminal. The browser OAuth flow completes and Claude Code shows "Login successful" with the welcome banner displaying my correct name and organization. - Send any prompt — even just typing "hi".
- The response is immediately "Not logged in · Please run /login", despite the login having just succeeded.
Notes:
- Reproduces every time today; some earlier days the login held for a few hours before dropping on its own.
- Re-running /login produces the same result: success, then "Not logged in" on the next request.
- Reproduces on Claude Code 2.1.156 and 2.1.158, on two separate networks (home + office WiFi).
Already ruled out: no ANTHROPIC_API_KEY/ANTHROPIC_BASE_URL in env; clean global and project settings.json; Keychain credential deleted and recreated; system clock synced; not network-related (fails on two networks). The credentials file ~/.claude/.credentials.json is never written and no refreshToken is persisted — appears related to #37402.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.1.158
Claude Code Version
2.1.158
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗