Claude Code · Sign-in
OAuth token has expired / OAuth token revoked
Your saved Claude login stopped working: it expired and couldn’t refresh, or it was revoked.
Message
The exact error
Please run /login · API Error: 401 OAuth token has expired ...Also appears as:
- Revoked
- OAuth token revoked · Please run /login
- Non-interactive mode (-p) and the Agent SDK
- Failed to authenticate. API Error: 401 OAuth token has expired ...
Meaning
What it means
Claude Code signs in with OAuth and refreshes the token automatically. “Expired” means a refresh failed mid-session; “revoked” means you signed out everywhere or an admin removed access. Either way the saved login is no longer accepted.
Causes
Common causes
- A refresh failure, for example after the computer slept or the network dropped
- Signing out of all devices, or an admin revoking access
- An expired long-lived token in
CLAUDE_CODE_OAUTH_TOKEN
Fix
How to fix it
Sign in again
Run
/loginat the Claude Code prompt.For -p commands and SDK programs
Run
claudein the same environment and complete/login, then rerun your command. For automation, use an API key or generate a long-lived token withclaude setup-token.If you use CLAUDE_CODE_OAUTH_TOKEN
Claude Code keeps sending the value you set, so generate a fresh one with
claude setup-tokenand restart with it, or unset the variable and use/login.If it keeps happening
Check that your system clock is set automatically. See Not logged in for the macOS Keychain fix.
Related