claude-code - 💡(How to fix) Fix [DOCS] Authentication docs omit `/login` behavior when `CLAUDE_CODE_OAUTH_TOKEN` is set [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#52203Fetched 2026-04-23 07:33:50
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3
RAW_BUFFERClick to expand / collapse

Documentation Type

Unclear/confusing documentation

Documentation Location

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

Section/Topic

Credential management / Authentication precedence

Current Documentation

The authentication docs currently say:

When multiple credentials are present, Claude Code chooses one in this order:

  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.
  2. Subscription OAuth credentials from /login. This is the default for Claude Pro, Max, Team, and Enterprise users.

The environment variable reference also says:

CLAUDE_CODE_OAUTH_TOKEN | OAuth access token for Claude.ai authentication. Alternative to /login for SDK and automated environments. Takes precedence over keychain-stored credentials.

The quickstart page says:

Once logged in, your credentials are stored and you won't need to log in again. To switch accounts later, use the /login command.

These pages do not explain what happens if an interactive session starts with CLAUDE_CODE_OAUTH_TOKEN and the user then runs /login.

What's Wrong or Missing?

Claude Code v2.1.118 fixed /login having no effect in a session launched with CLAUDE_CODE_OAUTH_TOKEN by clearing the env token so stored disk credentials take effect.

The current docs describe credential precedence and /login separately, but they do not document this interaction. As written, the docs imply that CLAUDE_CODE_OAUTH_TOKEN simply outranks stored /login credentials, without explaining that an interactive re-login now clears the session's env-token auth so the newly stored credentials become active.

That leaves an important user-visible behavior undocumented:

  • CLAUDE_CODE_OAUTH_TOKEN is presented as an alternative to /login for automation
  • /login is presented as the way to switch accounts later
  • but the docs never explain how /login behaves when the current session was launched with CLAUDE_CODE_OAUTH_TOKEN

Suggested Improvement

Add a short note under Authentication precedence (and mirror it in the env var reference) explaining that:

  1. CLAUDE_CODE_OAUTH_TOKEN is primarily for CI, scripts, and automated environments.
  2. If an interactive Claude Code session was launched with CLAUDE_CODE_OAUTH_TOKEN and the user runs /login or claude auth login, Claude Code clears that session's env-token auth so the newly stored disk credentials take effect.
  3. Users who want to switch accounts interactively should use /login, then verify the active auth method with /status.

This would make the precedence docs and the quickstart guidance consistent with the v2.1.118 behavior.

Impact

Medium - Makes feature difficult to understand

Additional Context

Affected Pages:

PageContext
https://code.claude.com/docs/en/authenticationAuthentication precedence and CLAUDE_CODE_OAUTH_TOKEN usage
https://code.claude.com/docs/en/env-varsEnv var reference currently says the token takes precedence over keychain-stored credentials
https://code.claude.com/docs/en/quickstartQuickstart says /login is how to switch accounts later

Total scope: 3 pages affected

Source: Changelog v2.1.118

Exact changelog entry:

Fixed /login having no effect in a session launched with CLAUDE_CODE_OAUTH_TOKEN — the env token is now cleared so disk credentials take effect

extent analysis

TL;DR

Update the documentation to clarify the interaction between CLAUDE_CODE_OAUTH_TOKEN and /login for interactive sessions.

Guidance

  • Add a note under Authentication precedence explaining that running /login in an interactive session launched with CLAUDE_CODE_OAUTH_TOKEN clears the session's env-token auth, allowing newly stored disk credentials to take effect.
  • Mirror this explanation in the environment variable reference for CLAUDE_CODE_OAUTH_TOKEN.
  • Emphasize that users who want to switch accounts interactively should use /login, then verify the active auth method with /status.
  • Review the affected pages (authentication, env-vars, and quickstart) to ensure consistency with the updated documentation.

Example

No code snippet is necessary for this documentation update.

Notes

The suggested improvement aims to clarify the behavior of /login in interactive sessions launched with CLAUDE_CODE_OAUTH_TOKEN, which was fixed in Claude Code v2.1.118. This update will make the documentation consistent with the current behavior.

Recommendation

Apply the suggested documentation update to clarify the interaction between CLAUDE_CODE_OAUTH_TOKEN and /login, as this will improve the understanding of the feature and make it easier for users to manage their credentials.

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 omit `/login` behavior when `CLAUDE_CODE_OAUTH_TOKEN` is set [1 participants]