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

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

Open bartlomein opened this issue 1 year ago • 38 comments

Environment

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

Bug Description

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":"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}
  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)```

bartlomein avatar Aug 05 '25 14:08 bartlomein

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

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

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!

duanehutchins avatar Aug 05 '25 17:08 duanehutchins

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

bartlomein avatar Aug 05 '25 17:08 bartlomein

Same issue but downgrading does not solve the problem

austinbv avatar Aug 05 '25 20:08 austinbv

seeing this too

noah-wardlow avatar Aug 05 '25 22:08 noah-wardlow

Same issue here

hugofreire avatar Aug 05 '25 23:08 hugofreire

+1

alexandercollinsnano avatar Aug 06 '25 00:08 alexandercollinsnano

Same issue but downgrading does not solve the problem

LeenluTo avatar Aug 06 '25 03:08 LeenluTo

+1

balibou avatar Aug 06 '25 06:08 balibou

same issue

ndemeshchenko avatar Aug 06 '25 07:08 ndemeshchenko

I have the same issue.

apue avatar Aug 06 '25 07:08 apue

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.

mattisfat avatar Aug 06 '25 07:08 mattisfat

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 avatar Aug 06 '25 08:08 bartlomein

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/[email protected] 2. mv ~/.claude ~/.claude.backup Move the local claude files over 3. Remove the alias to claude from .zshrc 4. start a new terminal 5. claude

bartlomein avatar Aug 06 '25 12:08 bartlomein

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.

titofebus avatar Aug 08 '25 12:08 titofebus

Still happening for me on Mac

zein1016 avatar Aug 10 '25 16:08 zein1016

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

noah-wardlow avatar Aug 11 '25 19:08 noah-wardlow

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

ArtemXTech avatar Aug 13 '25 16:08 ArtemXTech

Same here

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

forcedfakelaugh avatar Aug 14 '25 07:08 forcedfakelaugh

same here!

alex4nder1998 avatar Aug 14 '25 08:08 alex4nder1998