Claude Code: OAuth token has expired. Please obtain a new token or refresh your existing token.
The saved claude.ai login, or the token in CLAUDE_CODE_OAUTH_TOKEN, expired and the automatic refresh didn't succeed, so the API answered 401 and Claude Code passed its message through. The exact message, why Claude Code prints it, and the fix.
Updated November 23, 2026
The message
OAuth token has expired. Please obtain a new token or refresh your existing token.
What it means
The saved claude.ai login, or the token in CLAUDE_CODE_OAUTH_TOKEN, expired and the automatic refresh didn’t succeed, so the API answered 401 and Claude Code passed its message through.
Fix
- Run /login at the Claude Code prompt (or
claude auth login) to sign in again. - For
claude -pjobs and Agent SDK programs that use a saved login, runclaudein the same environment, complete /login, then rerun the job. - If you authenticate with CLAUDE_CODE_OAUTH_TOKEN, generate a fresh token with
claude setup-tokenand restart with it, or unset the variable and use /login. - If you’re asked to log in on every launch, check the system clock and follow the credential-storage steps under ‘Not logged in or token expired’ in the Troubleshoot installation and login page.
In an EnvHaven workspace
Yes, until Claude Code is signed in once. Sign in once from the workspace’s Launch menu (Sign in, or Set key for an API key); the sign-in stays on the workspace, across restarts and on every device.
Where this comes from
From Claude Code’s documentation and issue tracker: