claude-code - 💡(How to fix) Fix [DOCS] Authentication docs missing recovery guidance for expired `CLAUDE_CODE_OAUTH_TOKEN` [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#51784Fetched 2026-04-22 07:52:56
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3
RAW_BUFFERClick to expand / collapse

Documentation Type

Missing documentation (feature not documented)

Documentation Location

https://code.claude.com/docs/en/authentication

Section/Topic

"Credential management", "Authentication precedence", and "Generate a long-lived token"

Current Documentation

The docs currently say:

  1. CLAUDE_CODE_OAUTH_TOKEN environment variable. A long-lived OAuth token generated by claude setup-token. Use this for CI pipelines and scripts where browser login isn't available.

The command walks you through OAuth authorization and prints a token to the terminal. It does not save the token anywhere; copy it and set it as the CLAUDE_CODE_OAUTH_TOKEN environment variable wherever you want to authenticate:

If Claude Code prompts you to log in again after a session, your OAuth token may have expired.

Run /login to re-authenticate. If this happens frequently, check that your system clock is accurate, as token validation depends on correct timestamps.

What's Wrong or Missing?

Changelog v2.1.117 includes: "Fixed /login having no effect when launched with CLAUDE_CODE_OAUTH_TOKEN env var and that token expires".

That fix exposes a user-facing authentication path the docs do not currently explain: what should happen when Claude Code is launched with CLAUDE_CODE_OAUTH_TOKEN, that token later expires, and the user tries to recover interactively.

The current docs explain that CLAUDE_CODE_OAUTH_TOKEN is an alternative to /login and that expired OAuth sessions should be fixed with /login, but they do not connect those two cases. They do not say whether /login is expected to recover from an expired env-var token, whether users need to remove the environment variable first, or when they should use the refresh-token flow instead.

Suggested Improvement

Add a short subsection to the authentication or troubleshooting docs for expired env-var OAuth credentials, for example "When CLAUDE_CODE_OAUTH_TOKEN expires".

That section should clarify:

  • the intended interaction between CLAUDE_CODE_OAUTH_TOKEN and /login / claude auth login
  • the supported recovery path after an env-var OAuth token expires in an interactive session
  • when to prefer CLAUDE_CODE_OAUTH_REFRESH_TOKEN plus CLAUDE_CODE_OAUTH_SCOPES for renewable automated authentication instead of a fixed access token
  • how to verify which auth method is active with /status

Impact

Medium - Makes feature difficult to understand

Additional Context

Affected Pages:

PageContext
https://code.claude.com/docs/en/authenticationDocuments auth precedence and claude setup-token, but not expired CLAUDE_CODE_OAUTH_TOKEN recovery
https://code.claude.com/docs/en/env-varsLists CLAUDE_CODE_OAUTH_TOKEN, CLAUDE_CODE_OAUTH_REFRESH_TOKEN, and CLAUDE_CODE_OAUTH_SCOPES without explaining the recovery path when the access token expires
https://code.claude.com/docs/en/troubleshootingGives generic expired OAuth guidance (/login), but not the env-var-token case
https://code.claude.com/docs/en/cli-referenceLists claude auth login and claude setup-token, but not when to use each after env-var token expiration

Total scope: 4 pages affected

Source: Changelog v2.1.117

Exact changelog entry: Fixed /login having no effect when launched with CLAUDE_CODE_OAUTH_TOKEN env var and that token expires

extent analysis

TL;DR

Update the documentation to clarify the recovery path for expired CLAUDE_CODE_OAUTH_TOKEN environment variables, including the interaction with /login and the use of refresh tokens.

Guidance

  • Add a new subsection to the authentication documentation to explain the intended interaction between CLAUDE_CODE_OAUTH_TOKEN and /login or claude auth login when the token expires.
  • Clarify the supported recovery path after an env-var OAuth token expires in an interactive session, including when to use CLAUDE_CODE_OAUTH_REFRESH_TOKEN and CLAUDE_CODE_OAUTH_SCOPES.
  • Provide instructions on how to verify which authentication method is active using /status.
  • Review the affected pages (authentication, env-vars, troubleshooting, and CLI reference) to ensure consistent and accurate information.

Example

No code snippet is provided as this issue is related to documentation updates.

Notes

The current documentation lacks clarity on the recovery path for expired CLAUDE_CODE_OAUTH_TOKEN environment variables, leading to confusion for users. Updating the documentation will help resolve this issue.

Recommendation

Apply a workaround by adding a new subsection to the authentication documentation to clarify the recovery path for expired CLAUDE_CODE_OAUTH_TOKEN environment variables. This will provide users with clear instructions on how to recover from an expired token and improve the overall user experience.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [DOCS] Authentication docs missing recovery guidance for expired `CLAUDE_CODE_OAUTH_TOKEN` [1 participants]