OAuth token expired — login/logout/all commands fail with 401, no recovery path
Bug Description
When the OAuth token expires, every Claude Code command fails with a 401 error — including the commands meant to fix it (claude login, claude logout, claude /login). There is no way to recover from this state through the CLI itself.
Steps to Reproduce
- Use Claude Code normally until the OAuth token expires
- Any command (
claude,hello, etc.) returns:
````
API Error: 401
{"type":"error","error":{"type":"authentication_error","message":"OAuth token has expired. Please obtain a new token or refresh your existing token."}} · Please run /login
- Running
claude /login→ same 401 error - Running
claude login→ same 401 error - Running
claude logout→ same 401 error - Running
claude(fresh) → same 401 error
Expected Behavior
At minimum, claude login and claude logout should work without requiring a valid token, since their purpose is to obtain/reset one.
Environment
- macOS (Darwin)
- Claude Code using Claude API (Sonnet 4.6)
- OAuth authentication
Additional Context
This is a recurring issue — it happens repeatedly and each time requires manual workarounds (deleting auth files, setting API keys via env vars, etc.) to recover. The login flow should not depend on having a valid token.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗