ThinkFacility

Error messages

OAuth token has expired. Please obtain a new token or refresh your existing token.

The message

OAuth token has expired. Please obtain a new token or refresh your existing token.
Claude Code 2.1.280 read September 23, 2026Claude Codeauthentication401

What it means

Your sign-in's short-lived access token ran out and Claude Code's automatic refresh didn't replace it in time, so the API turned the request away with a 401.

What to do

Run /login. If it comes back in the same session, run /logout first and then /login. Update Claude Code if you're on an old version.

This sentence comes from Anthropic's API, and Claude Code passes it on with a 401 (the HTTP code for "not authenticated") and a hint to sign in again. It's what the API says when the access token from your claude.ai sign-in is past its expiry. In a January report on version 2.1.7 the whole line looked like this:

API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"OAuth token has expired. Please obtain a new token or refresh your existing token."},"request_id":"req_011CX7zT7Swc35VFkEUZ57Fo"} · Please run /login

The part people search is the middle:

OAuth token has expired. Please obtain a new token or refresh your existing token.

146 issues in anthropics/claude-code contain "OAuth token has expired" as of September 23, 2026. That January reporter had been using Claude Code for months and got it three times in under five hours, and two other people replied the same day to say they were seeing it too.

Why it happens when Claude Code refreshes tokens itself

Your sign-in holds two things: an access token that expires quickly, and a refresh token Claude Code uses to get a new one without bothering you. Anthropic's error reference puts it in one clause: "an expired token means the automatic refresh failed mid-session." So the message means the refresh broke. Nobody signed you out on purpose.

The changelog shows how many ways that refresh has gone wrong. Version 2.1.0 fixed a refresh that didn't fire when the server said the token had expired but the local clock disagreed. 2.1.117 fixed sessions dying with "Please run /login" when the token expired mid-session, and made Claude Code refresh when it gets a 401. 2.1.129 fixed a race after waking from sleep "that could log out all running sessions". If you're well behind those versions, updating is the first fix.

What to do

Run /login. If the error comes back later in the same session, the error reference says to run /logout first so the stored token is fully cleared, then /login again.

If the saved login has already been wiped after a failed refresh, you get a Claude Code line instead of the API's sentence, Login expired · Please run /login, and the fix is the same.

If you use CLAUDE_CODE_OAUTH_TOKEN

The long-lived token from claude setup-token, passed in CLAUDE_CODE_OAUTH_TOKEN, gets the same message when it expires. Claude Code keeps sending the value you set even after a 401, so running /login in that session won't help. Make a fresh token with claude setup-token and restart with it, or unset the variable and sign in normally. The error reference adds that before v2.1.225, Claude Code could swap the variable's value mid-session for a stored login's short-lived token, which then expired in turn.

A July report found a related trap: with a valid token in the variable and a stale ~/.claude/.credentials.json on disk, Claude Code still reported the token as expired, and deleting the file fixed it. That issue was closed by the stale bot without an answer, so it's worth trying if nothing else works.

For "Not logged in" and "Invalid API key", which mean something different, see Not logged in · Please run /login.

Other lines the same feature prints

Match yours against these if the one at the top of the page is not quite it. They come from the same code and mean related things.

  • Please run /login · API Error: 401 OAuth token has expired
  • OAuth token revoked · Please run /login
  • Login expired · Please run /login