[BUG] Missing API key · Run /login on Max subscription

Resolved 💬 38 comments Opened Aug 5, 2025 by bartlomein Closed Jan 10, 2026

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

  1. /login
  2. 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)```

View original on GitHub ↗

38 Comments

github-actions[bot] · 11 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/5118
  2. https://github.com/anthropics/claude-code/issues/2227
  3. https://github.com/anthropics/claude-code/issues/5151

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

🤖 Generated with Claude Code

duanehutchins · 11 months ago

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.json file 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!

bartlomein · 11 months ago

@duanehutchins Thanks! I did end up downgrading to the lower version. not ideal but going to work with that until there is a fix

austinbv · 11 months ago

Same issue but downgrading does not solve the problem

noah-wardlow · 11 months ago

seeing this too

hugofreire · 11 months ago

Same issue here

alexandercollinsnano · 11 months ago

+1

LeenluTo · 11 months ago

Same issue but downgrading does not solve the problem

balibou · 11 months ago

+1

ndemeshchenko · 11 months ago

same issue

apue · 11 months ago

I have the same issue.

mattisfat · 11 months ago

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>

bartlomein · 11 months ago

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

bartlomein · 11 months ago

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.67

  1. mv ~/.claude ~/.claude.backup Move the local claude files over
  2. Remove the alias to claude from .zshrc
  3. start a new terminal
  4. claude
titofebus · 11 months ago

This issue is still happening I'm noticing it happens every day maybe 24 hours? The way I fix it is:

  1. Uninstall Claude Code
  2. Install 1.00.67
  3. LogIn
  4. /Exit
  5. Open Claude Code

This resolves the problem temporarily for at least 24 hours.

Seeing most people have this problem with SSH and mosh.

zein1016 · 11 months ago

Still happening for me on Mac

noah-wardlow · 11 months ago

still happening for me too. having to constantly downgrade versions and re-login

ArtemXTech · 11 months ago

The same issue here. Downgrading is working, but not ideal. I ssh into my host and run Claude Code there

forcedfakelaugh · 11 months ago

Same here

The same issue here. Downgrading is working, but not ideal. I ssh into my host and run Claude Code there
alex4nder1998 · 11 months ago

same here!

tazmattar · 11 months ago

Same here on Mac. I've tried to uninstall, reinstall, downgrade and no change at all.

ijbaird · 11 months ago

+1

mattisfat · 11 months ago

So to get round this, I have been running:

security unlock-keychain ~/Library/Keychains/login.keychain-db

before starting CC, which requires you to put in your password.

Then run:

claude login

Do the auth process if you have to,

CREAITIVE-THINKING · 11 months ago

Having same issue.

mantas-deblock · 11 months ago

exact same issue happening on Mac

smclelland · 10 months ago

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-token

Put token in env
export CLAUDE_CODE_OAUTH_TOKEN=<token>

smclelland · 10 months ago

As others have pointed out. Using setup-token works, 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 claude the 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!

JunYang-tes · 10 months ago

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)

Hermanverschooten · 10 months ago

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.

JunYang-tes · 10 months ago

Add customApiKeyResponses to claude setting.
if you are using linux, edit ~/.claude.json:

{
  "customApiKeyResponses": {
    "approved":[
      "last 20 chars of YOUR-API-KEY"
    ]
  }
}

Works for me perfectly.

---

@jrobinson-svg @ionutz89, I holp this information would helpful for you.

PanGalactic · 10 months ago

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!

masszhou · 9 months ago

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/

afiaka87 · 9 months ago

Nothing works.

timyal · 9 months ago

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

NG-Bullseye · 8 months ago

security unlock-keychain ~/Library/Keychains/login.keychain-db

github-actions[bot] · 7 months ago

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.

github-actions[bot] · 6 months ago

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.

github-actions[bot] · 5 months ago

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.