claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] macOS OAuth authentication succeeds but auth token not persisted - shows 'Missing API key' after successful login

Open timyal opened this issue 1 year ago • 23 comments

Environment

  • Platform (select one):
    • [X] Anthropic API
    • [ ] AWS Bedrock
    • [ ] Google Vertex AI
    • [ ] Other:
  • Claude CLI version: 1.0.69
  • Operating System: macOS 15.5
  • Terminal: Termius

Bug Description

OAuth authentication completes successfully but auth token is not persisted. After successful login with Claude Max subscription, Claude Code shows "Missing API key · Run /login" and /status shows "Auth Token: none".

Steps to Reproduce

  1. Install Claude Code (tried both npm install -g @anthropic-ai/claude-code and native installer)
  2. Run claude in project directory
  3. Run /login
  4. Select "1. Claude account with subscription"
  5. Complete OAuth flow in browser (shows "Login successful" and "You're all set up for Claude Code")
  6. Return to terminal - see "Login successful" message
  7. Try any command (e.g., "Are you there?")
  8. And you get "Invalid API key · Please run /login"

Expected Behavior

After successful OAuth authentication, Claude Code should store the auth token and allow normal usage with Claude Max subscription.

Actual Behavior

  • OAuth completes successfully in browser
  • Terminal shows "Login successful"
  • Any command returns "Invalid API key · Please run /login"
  • /status shows "Auth Token: none"
  • No credentials found in macOS keychain or filesystem
  • Issue persists across both npm and native installations

Additional Context

Have active Claude Max subscription Tested with both npm global installation and native installer - same issue No credential files created in ~/.claude/ directory Multiple login attempts all show same behavior claude doctor shows installation is healthy Issue appears to be with credential storage/retrieval, not OAuth flow itself

timyal avatar Aug 06 '25 14:08 timyal

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/5225
  2. https://github.com/anthropics/claude-code/issues/5166
  3. https://github.com/anthropics/claude-code/issues/5167

If your issue is a duplicate, please close it and 👍 the existing issue instead.

This issue will be automatically closed as a duplicate in 3 days if there are no additional comments. To prevent auto-closure, please 👎 this comment.

🤖 Generated with Claude Code

github-actions[bot] avatar Aug 06 '25 14:08 github-actions[bot]

Tested with multiple installation methods:

  • npm global installation: Same issue
  • Native installation with conflicts: Same issue
  • Clean, single native installation: Same issue

Latest claude doctor output (clean installation): Diagnostics └ Currently running: native (1.0.69) └ Path: /Users/timuryalcin/.local/bin/claude └ Config install method: native └ Auto-updates enabled: true

OAuth flow consistently works, but credentials are never persisted.

timyal avatar Aug 06 '25 14:08 timyal

Downgrading to 1.0.67 also did not work for me...

Still Missing API key · Run /login

timyal avatar Aug 06 '25 14:08 timyal

Closing claude, and reopening did the trick AFTER the downgrade!!!

timyal avatar Aug 06 '25 14:08 timyal

https://github.com/anthropics/claude-code/issues/1222#issuecomment-3013457571 fixed it for me running on 1.0.69

nodnarbnitram avatar Aug 06 '25 18:08 nodnarbnitram

I also downgraded to 1.0.67 to make it work. sorry for being a novice, but, how will we know when this is fixed? just follow this open bug?

jacoblhess avatar Aug 07 '25 03:08 jacoblhess

I have the same issue with the 1.0.70 version. It's really annoying.

vincent-herlemont avatar Aug 07 '25 17:08 vincent-herlemont

I have this issue with v1.0.71. after uninstalling and reinstalling multiple times it now works. I had the issue originally with just the npm installed version. I then install the native version still had the issue. Then I uninstalled and reinstalled both the npm version and the native version, leaving only the native version and this now appears to work. Seems more likely that there's invalid state in the install than any particular version actually being a part of the bug. Difficult to diagnose.

AFDudley avatar Aug 08 '25 00:08 AFDudley

same issue

icaca avatar Aug 10 '25 07:08 icaca

I thought I turned autoupdate off. It seems to have autoupdated anyway. The bug was reintroduced, I manually downgraded to 1.0.67 by remove .71 and .72 and then setting the symlink. .67 failed to login, but at some point it downloaded .72 and switched the symlink. I restarted my terminal. This feels like The Shining, .72 works. But it seems as though it requires failing via .67 at some point. Also I'm logging in a lot during this process.

AFDudley avatar Aug 10 '25 16:08 AFDudley

❯ claude doctor

 Diagnostics
 └ Currently running: npm-global (1.0.72)
 └ Path: /opt/homebrew/Cellar/node/24.4.1/bin/node
 └ Invoked: /opt/homebrew/bin/claude
 └ Config install method: unknown
 └ Auto-updates enabled: true
 └ Update permissions: Yes

 Agent Configurations
 └ Loaded custom agents: 0

I get this Config install method: unknown, which might be the problem.

NightMachinery avatar Aug 10 '25 19:08 NightMachinery

I have the same issue whatever version I tried >1.0.67. Would be nice to fix it, it's very annoying thanks

yplassiard avatar Aug 22 '25 12:08 yplassiard

Same here, very annoying

coloboxp avatar Aug 22 '25 16:08 coloboxp

I had this issue for a while and it turned out to be that I had modified PATH in my claude env in .claude/settings.json. I'm not sure why this caused an issue because it should have had the rest of the previous PATH there, but it did.

So with the following line I kept getting the error, but removing the setting of PATH fixed it.

{
  "env": {
    "PATH": "$PATH:/Users/myuser/.venv/bin",
    ...
  },
  ...
}

MichaelDanielTom avatar Aug 22 '25 17:08 MichaelDanielTom

Been fighting this all day. None of the suggestions here worked for me.

However, this worked: curl -fsSL https://claude.ai/install.sh | bash

From here: https://docs.anthropic.com/en/docs/claude-code/setup

potable-anarchy avatar Aug 23 '25 23:08 potable-anarchy

Been fighting this all day. None of the suggestions here worked for me.

However, this worked: curl -fsSL https://claude.ai/install.sh | bash

From here: https://docs.anthropic.com/en/docs/claude-code/setup

Thanks, I have been troubled by this issue for half a month. your method works for me too!

YuanZongjian avatar Aug 29 '25 07:08 YuanZongjian

Still unresolved. I haven't been able to login since v1.0.67.

None of the tips above work. Other coding CLIs work perfectly fine, I've been using Codex much more because it works, but would love to see this fixed!

svilupp avatar Oct 11 '25 19:10 svilupp

I may have successfuly fixed this doing the following, providing that I'm running from MacOS.

Potential root cause

It seems that Claude-code stores the credentials into the Session keychain. The thing is that in my setup, I'm running it via ssh so I'm not opening a "real" MacOS session, and therefore do not unlock the keychain, which leads to the error shown.

Solution

Use '''security unlock''' to unlock the desired keychain before invoking claude-code, and ideally when opening a session.

yplassiard avatar Oct 12 '25 18:10 yplassiard

Use '''security unlock''' to unlock the desired keychain before invoking claude-code, and ideally when opening a session.

This worked for me too! Thanks @yplassiard

pythoninthegrass avatar Oct 31 '25 17:10 pythoninthegrass

Same issue here had to file a chargeback with Amex as my Max plan renewed days ago and since then I have not been able to use it at all; nothing but endless /login loops.

lmoreau avatar Nov 11 '25 19:11 lmoreau