Home/Wiki Errors/Claude Code
Claude Code / OAuth/Auth

Not logged in - Please run /login - Claude Code

Claude Code cannot use the current local credential. The token may be expired, revoked, tied to a disabled organization, or shadowed by the wrong API key environment variable.

Claude Code login loopClaude Code OAuth token revokedClaude Code invalid API key
Paste an error to match it against the wiki. / 粘贴报错后自动匹配。

Error text / 报错原文

  • Not logged in · Please run /login
  • OAuth token revoked
  • OAuth token has expired
  • Invalid API key

What it means

Claude Code cannot use the current local credential. The token may be expired, revoked, tied to a disabled organization, or shadowed by the wrong API key environment variable.

Most common causes

  • Browser login completed but the CLI token cache stayed stale
  • ANTHROPIC_API_KEY points to the wrong key
  • A corporate proxy or browser profile blocked OAuth callback
  • The account or organization no longer has access

Fastest fix

  • Run /logout, close Claude Code, then run claude and login again
  • Check whether ANTHROPIC_API_KEY is set in the terminal
  • Try a clean browser profile for the OAuth flow
  • If the local auth file is corrupt, remove only the Claude Code auth file and login again

Safe fix

  • Use organization-managed keys for CI, not personal browser OAuth
  • Store keys in a secret manager or shell profile with limited scope
  • Keep browser and terminal on the same user account
  • Document which auth mode each machine uses

What not to do

  • Do not paste OAuth tokens into project config
  • Do not commit auth.json or shell history
  • Do not use sudo to force npm or auth paths

How to confirm the fix

Run the smallest reproducible command first, then retry the agent task only after authentication, quota, and tool discovery are stable.

claude doctor
echo $ANTHROPIC_API_KEY
which claude

Related errors

Related tools

Sources