Paste an error to match it against the wiki. / 粘贴报错后自动匹配。
Error text / 报错原文
Not logged in · Please run /loginOAuth token revokedOAuth token has expiredInvalid 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
- You've hit your session limit / weekly limit - Claude Code →
- Prompt is too long - Claude Code context window →
- API Error: Repeated 529 Overloaded errors - Claude Code →
- MCP servers failed to connect - Claude Code →
- Failed to exchange authorization code for token - Antigravity →
- Failed to get OAuth token: state syncing error: key not found - Antigravity →