Skip to content
AI Dev Toolkit.
Esc
  • AI Token CounterCount tokens for GPT, Claude, Gemini, DeepSeek, Qwen and more.Tool
  • LLM API Cost CalculatorEstimate per-request, daily and monthly API costs.Tool
  • AI Model ComparisonCompare prices, context windows and features across models.Tool
  • AI Model Pricing PagesSpecs, real costs and cheaper alternatives for popular models.Tool
  • Context Window CheckerSee whether your text fits each model's context window.Tool
  • Subscription vs API CalculatorFind out whether a chat plan or the API is cheaper for you.Tool
  • GPU / VRAM CalculatorCheck how much VRAM a local model needs and which GPUs fit.Tool
  • Claude Code Error DatabaseExact Claude Code error messages with tested fixes.Tool

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

Claude Code
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

  1. Sign in again

    Run /login at the Claude Code prompt.

  2. For -p commands and SDK programs

    Run claude in the same environment and complete /login, then rerun your command. For automation, use an API key or generate a long-lived token with claude setup-token.

  3. If you use CLAUDE_CODE_OAUTH_TOKEN

    Claude Code keeps sending the value you set, so generate a fresh one with claude setup-token and restart with it, or unset the variable and use /login.

  4. If it keeps happening

    Check that your system clock is set automatically. See Not logged in for the macOS Keychain fix.

Related

Search all Claude Code errors