CLAUDE_CODE_OAUTH_TOKEN
A Claude Code environment variable, read out of the shipped bundle. It has been in the build since v2.1.138, including the newest one read.
What it is
OAuth access token for claude.ai authentication. Alternative to /login for SDK and automated environments. Takes precedence over keychain-stored credentials. Generate one with [claude setup-token](/docs/en/authentication#generate-a-long-lived-token). Unless you run [/login](/docs/en/authentication#authentication-precedence), Claude Code uses the token you set for the whole session. To replace an expired token, generate a new one and restart
Anthropic's own wording. Read off Environment variables, captured 2026-08-28.
Presence across releases
| Releases | Reading | Declared type | Default |
|---|---|---|---|
| 2.1.245 – 2.1.250 5 releases | never mined | — | — |
| 2.1.160 – 2.1.243 75 releases | in the build | str | — |
| 2.1.138 – 2.1.159 20 releases | in the build | — | — |
A row reading never mined is a release with no archived bundle behind it. Nothing was read out of it, so nothing here says whether the name was in it. A declared type or a default is only ever what that release's own bundle stated.
Changelog entries naming it
-
v2.1.246Credentials are primed through the store at start-up
Login tokens are warmed at startup, and skipped entirely for token-based auth.
named in this entry
-
v2.1.234The CLAUDE_CODE_OAUTH_TOKEN login warning can arrive as its own message
The warning about a set OAuth token env var can now arrive as its own message after login.
named in this entry
-
v2.1.229/login warns if an OAuth token is set in your environment
After logging in, you're warned if an OAuth token in your environment will override it later.
named in this entry
-
v2.1.229OAuth token warning no longer tells you to unset the variable
The OAuth token login warning now correctly says your session switches to the new credentials.
named in this entry
-
v2.1.225OAuth 401 recovery no longer silently replaces a user-supplied token
Your explicitly set OAuth token is no longer silently swapped for a stored credential after a 401.
named in this entry
-
v2.1.223Clearer failures when claude.ai project scopes can't be obtained
When project permissions fail, you now get a specific reason and advice instead of a vague error.
named in this entry
-
v2.1.223Settings-supplied API and credential env vars are stripped when ANTHROPIC_UNIX_SOCKET is set
When you connect through a unix socket, settings files can no longer override your API keys or endpoint.
named in this entry
-
v2.1.221Artifact credentials and artifact base URLs are stripped from child process environments
Artifact tokens and artifact base URLs no longer leak into processes Claude spawns.
named in this entry
Documentation pages
- Environment variables reference table Claude Code CLI
- Use Claude Code features in the SDK mentions it Claude Code CLI
- Authentication mentions it Claude Code CLI
- Claude Code changelog mentions it Claude Code CLI
- Development containers mentions it Claude Code CLI
- Error reference mentions it Claude Code CLI
- Claude Code GitHub Actions mentions it Claude Code CLI
- Connect Claude Code to an LLM gateway mentions it Claude Code CLI
- Connect Claude Code to tools via MCP mentions it Claude Code CLI
- Continue local sessions from any device with Remote Control mentions it Claude Code CLI
- Customize sessions in self-hosted environments mentions it Claude Code CLI
- Configure server-managed settings mentions it Claude Code CLI
A reference table page is one whose own table defines this name, and it is where the description above came from. A page that mentions it carries the name somewhere in its text and may say nothing about it at all. Every page carrying it.
Names beside it
Every environment variable in the inventory starting claude_code_oauth, up to twelve of them.
CLAUDE_CODE_OAUTH_401_WAIT_MSNo description from anybody. 2.1.163
CLAUDE_CODE_OAUTH_CLIENT_IDNo description from anybody. 2.1.138
CLAUDE_CODE_OAUTH_REFRESH_TOKENOAuth refresh token for Claude.ai authentication. When set, claude auth login exchanges this token directly instead of opening a browser. Requires CLAUDE_CODE_OAUTH_SCOPES. Useful for provisioning authentication in automated environments 2.1.138
CLAUDE_CODE_OAUTH_SCOPESSpace-separated OAuth scopes the refresh token was issued with, such as "user:profile user:inference user:sessions:claude_code". Required when CLAUDE_CODE_OAUTH_REFRESH_TOKEN is set 2.1.138
CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTORLogin tokens are warmed at startup, and skipped entirely for token-based auth. 2.1.138
Read out of the published npm bundle release by release, and out of Anthropic's own documentation as this site captured it. Nothing on this page is a description anybody here wrote about what the environment variable does. All environment variables.