# 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

```text
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

1. Run /login at the Claude Code prompt (or `claude auth login`) to sign in again.
2. For `claude -p` jobs and Agent SDK programs that use a saved login, run `claude` in the same environment, complete /login, then rerun the job.
3. If you authenticate with CLAUDE_CODE_OAUTH_TOKEN, generate a fresh token with `claude setup-token` and restart with it, or unset the variable and use /login.
4. 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:

- [github.com/anthropics/claude-code/issues/18225](https://github.com/anthropics/claude-code/issues/18225)
- [github.com/anthropics/claude-code/issues/12447](https://github.com/anthropics/claude-code/issues/12447)
- [code.claude.com/docs/en/errors#oauth-token-revoked-or-expired](https://code.claude.com/docs/en/errors#oauth-token-revoked-or-expired)
- [code.claude.com/docs/en/errors#oauth-token-revoked-or-expired](https://code.claude.com/docs/en/errors#oauth-token-revoked-or-expired)

## Keep reading

- [Claude Code](https://envhaven.com/agents/claude-code)
- [Is Claude Code down?](https://envhaven.com/status/claude-code)
- [Every agent error](https://envhaven.com/errors)

Source: https://envhaven.com/errors/claude-code/oauth-token-has-expired
