OAuth token expired — login/logout/all commands fail with 401, no recovery path

Resolved 💬 4 comments Opened Mar 13, 2026 by annieha Closed Mar 16, 2026

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

  1. Use Claude Code normally until the OAuth token expires
  2. 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
``

  1. Running claude /login → same 401 error
  2. Running claude login → same 401 error
  3. Running claude logout → same 401 error
  4. 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.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗