[BUG] Missing API key · Run /login on Max subscription
Environment
- Platform (select one):
- [ ] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: <!-- output of
claude --version--> - Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 -->
- Terminal: <!-- e.g. iTerm2, Terminal App -->
Bug Description
<!-- A clear and concise description of the bug -->
Steps to Reproduce
- /login
- Missing API key · Run /login
Expected Behavior
I can't login
Actual Behavior
Missing API key · Run /login
After logging in i keep getting this error which means I cant use it.
Additional Context
```{"parentUuid":null,"isSidechain":false,"userType":"external","cwd":"/Users/bart/dev/test1","sessionId":"395e3f13-6a61-4ff6-ac0c-6e8bd41932f4","version":"1.0.68","gitBranch":"","type":"user","message":{"role":"user","content":"teats"},"uuid":"ce9c9849-37a2-4d68-9795-052a7f153cd4","timestamp":"2025-08-05T14:47:28.821Z"}
{"parentUuid":"ce9c9849-37a2-4d68-9795-052a7f153cd4","isSidechain":false,"userType":"external","cwd":"/Users/bart/dev/test1","sessionId":"395e3f13-6a61-4ff6-ac0c-6e8bd41932f4","version":"1.0.68","gitBranch":"","type":"assistant","uuid":"3be84e01-19bf-4c67-af8a-fbcd9baa6090","timestamp":"2025-08-05T14:47:29.133Z","message":{"id":"4da51a71-a4c5-4ca8-99d2-34fc1067c869","model":"<synthetic>","role":"assistant","stop_reason":"stop_sequence","stop_sequence":"","type":"message","usage":{"input_tokens":0,"output_tokens":0,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"server_tool_use":{"web_search_requests":0},"service_tier":null},"content":[{"type":"text","text":"Invalid API key · Please run /login"}]},"isApiErrorMessage":true}
{"parentUuid":"3be84e01-19bf-4c67-af8a-fbcd9baa6090","isSidechain":false,"userType":"external","cwd":"/Users/bart/dev/test1","sessionId":"395e3f13-6a61-4ff6-ac0c-6e8bd41932f4","version":"1.0.68","gitBranch":"","type":"user","message":{"role":"user","content":"Caveat: The messages below were generated by the user while running local commands. DO NOT respond to these messages or otherwise consider them in your response unless the user explicitly asks you to."},"isMeta":true,"uuid":"21dd5df6-d39d-4d04-9f00-eba643e12137","timestamp":"2025-08-05T14:47:44.447Z"}
{"parentUuid":"21dd5df6-d39d-4d04-9f00-eba643e12137","isSidechain":false,"userType":"external","cwd":"/Users/bart/dev/test1","sessionId":"395e3f13-6a61-4ff6-ac0c-6e8bd41932f4","version":"1.0.68","gitBranch":"","type":"user","message":{"role":"user","content":"<command-name>/login</command-name>\n <command-message>login</command-message>\n <command-args></command-args>"},"uuid":"31b57fb0-ff0c-4ce1-9825-116351dc8895","timestamp":"2025-08-05T14:47:44.446Z"}
{"parentUuid":"31b57fb0-ff0c-4ce1-9825-116351dc8895","isSidechain":false,"userType":"external","cwd":"/Users/bart/dev/test1","sessionId":"395e3f13-6a61-4ff6-ac0c-6e8bd41932f4","version":"1.0.68","gitBranch":"","type":"user","message":{"role":"user","content":"<local-command-stdout>Login successful</local-command-stdout>"},"uuid":"456faac1-78ef-4613-9fd9-ad3c379a235d","timestamp":"2025-08-05T14:47:44.446Z"}
{"parentUuid":"456faac1-78ef-4613-9fd9-ad3c379a235d","isSidechain":false,"userType":"external","cwd":"/Users/bart/dev/test1","sessionId":"395e3f13-6a61-4ff6-ac0c-6e8bd41932f4","version":"1.0.68","gitBranch":"","type":"user","message":{"role":"user","content":"test"},"uuid":"1ba11670-b8c6-409a-8df9-a8681dc21191","timestamp":"2025-08-05T14:48:05.708Z"}
{"parentUuid":"1ba11670-b8c6-409a-8df9-a8681dc21191","isSidechain":false,"userType":"external","cwd":"/Users/bart/dev/test1","sessionId":"395e3f13-6a61-4ff6-ac0c-6e8bd41932f4","version":"1.0.68","gitBranch":"","type":"assistant","uuid":"0befaf20-1ac2-4c66-8a00-a927f7a562a4","timestamp":"2025-08-05T14:48:05.903Z","message":{"id":"2123b8d5-2456-4b7c-bff5-f67a02b4629c","model":"<synthetic>","role":"assistant","stop_reason":"stop_sequence","stop_sequence":"","type":"message","usage":{"input_tokens":0,"output_tokens":0,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"server_tool_use":{"web_search_requests":0},"service_tier":null},"content":[{"type":"text","text":"Invalid API key · Please run /login"}]},"isApiErrorMessage":true}
``` Claude Code v1.0.68
L Session ID: 63b87ca3-598a-47bb-9a95-2d932fcf5526
Working Directory
L /Users/bart/dev
Account
L Auth Token: none
Memory • /memory
L user: ~/.claude/CLAUDE.md
Model • /model
L Default (claude-sonnet-4-20250514)```
38 Comments
Found 3 possible duplicate issues:
If your issue is a duplicate, please close it and 👍 the existing issue instead.
🤖 Generated with Claude Code
Duplicated the issue here with a fresh install on a fresh machine. Authentication seems to work, but the client is not authenticated.
After logging into claude, it says the api key is invalid. Confirmed that the
.credentials.jsonfile doesn't exist, and there are no new API keys created in my Anthropic account.Temp workaround: I got this working on the new machine by copying the following files/directories from the old (working) device to the new device:
~/.claude/*~/.claude.json~/.claude.json.backup{[project/directory}}/.claude/*This uses the same API key for both machines, which is not ideal, but it got the new machine up and running. I'll re-auth once Anthropic fixes the bug.
Hopefully this helps!
@duanehutchins Thanks! I did end up downgrading to the lower version. not ideal but going to work with that until there is a fix
Same issue but downgrading does not solve the problem
seeing this too
Same issue here
+1
Same issue but downgrading does not solve the problem
+1
same issue
I have the same issue.
Same issue. I tried copying files from another machine per @duanehutchins suggestion. That removed the missing API key error, but meant I was working off my API account, which I don't want given I want to use my pro plan. So tried to login using my pro plan. Auth went through fine, but then the Missing API key error came back. </sigh>
I was able to downgrade to .67. That worked, then later on in the day i upgraded to .69 and that worked. Now I woke up and its happening again
I was able to downgrade to 1.0.67 and it worked. Here are my steps that helped me:
1.
npm install -g @anthropic-ai/claude-code@1.0.67mv ~/.claude ~/.claude.backupMove the local claude files over.zshrcclaudeThis issue is still happening I'm noticing it happens every day maybe 24 hours? The way I fix it is:
This resolves the problem temporarily for at least 24 hours.
Seeing most people have this problem with SSH and mosh.
Still happening for me on Mac
still happening for me too. having to constantly downgrade versions and re-login
The same issue here. Downgrading is working, but not ideal. I ssh into my host and run Claude Code there
Same here
same here!
Same here on Mac. I've tried to uninstall, reinstall, downgrade and no change at all.
+1
So to get round this, I have been running:
security unlock-keychain ~/Library/Keychains/login.keychain-dbbefore starting CC, which requires you to put in your password.
Then run:
claude loginDo the auth process if you have to,
Having same issue.
exact same issue happening on Mac
Was finally able to get this working on Mac. I tried all of the workarounds like unlock-keychain with no success. This finally worked:
Delete the keychain (seems to only exist with new builds)
security delete-generic-password -s "Claude Code-credentials"Request long-lived authentication token
claude setup-tokenPut token in env
export CLAUDE_CODE_OAUTH_TOKEN=<token>As others have pointed out. Using
setup-tokenworks, but it is a different auth flow (enterprise maybe?) and prevents interactive access to Opus and the config that comes with normal /login flow.Did some more digging and found that if I ran
sudo claudethe normal /login auth flow worked. It correctly created the Claude Code-credentials keychain entry. If I ran under my user then the keychain entry was never created, even using unlock-keychain.Finally discovered the issue. I was missing $USER env var and claude was failing to create the keychain entry for my user. With sudo, USER=root was automatically set.
In claude they are calling
security add-generic-password -U -a $USER -s "Claude Code-credentials"...Fix:
export USER=$(whoami)run claude, /login, successful login, says "No API Key", exit claude, run claude again, works!
Workaround:
Edit
@anthropic-ai/claude-code/cli.js<img width="729" height="280" alt="Image" src="https://github.com/user-attachments/assets/54831067-db48-42bf-81f5-6dea66a059d3" />
To find the path, run
ls -l $(which claude)I had the same issue. My dev machine is a Mac Mini, Sequoia 15.6.1.
I tend to use claude over an SSH connection to my dev machine where I run it inside tmux.
I connected and got the API error, do /login, which I did, pasted the code, the error stayed.
Tried it this morning 4 times, then I logged into my dev machine directly, got the same API error, did /login and lo an behold, it works.
It seems to me like something is not "written" or changed correctly when running /login while connected over SSH.
Add customApiKeyResponses to claude setting.
if you are using linux, edit
~/.claude.json:Works for me perfectly.
---
@jrobinson-svg @ionutz89, I holp this information would helpful for you.
To all those suggesting installing a key, you will find out the hard way that this will not use your max plan, but in fact charge your API account per response.
Anthropic, I am getting 0 help from your support team despite spending considerable amounts of my time meticulously troubleshooting the issue. It is not nice to ignore your users like this!
have the same issue from my macbook, tried everything from github but not working.
but this solution works from me
security unlock-keychain
source: https://www.reddit.com/r/ClaudeAI/comments/1n8qk4a/claude_code_login_issue_macos_fixed/
Nothing works.
In that terminal where Claude just started, first exit:
exit
Then run these commands in sequence:
Step 1: Unlock keychain
security unlock-keychain ~/Library/Keychains/login.keychain-db
(Enter your Mac password when prompted)
Step 2: Start Claude
claude
Then in the Claude session:
/login
Wait for "Login successful" (even though it will still show "Missing API key")
exit
Step 3: Start Claude again
claude
security unlock-keychain ~/Library/Keychains/login.keychain-db
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.