Onboarding flow ignores CLAUDE_CODE_OAUTH_TOKEN, blocks interactive CLI

Status Closed — not planned
Reported on v2.1.100
Maintainer reply None cached
Activity 6 comments · opened Apr 10, 2026 · closed Jun 26, 2026

Bug

When CLAUDE_CODE_OAUTH_TOKEN is set (e.g. via a token from claude setup-token on another machine), the interactive claude CLI still shows the full onboarding login screen, making it impossible to complete onboarding without doing the full OAuth login.

This means hasCompletedOnboarding never gets set, so the onboarding screen appears on every launch.

Root cause

In src/components/Onboarding.tsx, the oauth step is included whenever oauthEnabled is true:

if (oauthEnabled) {
    steps.push({
      id: 'oauth',
      component: <SkippableStep skip={skipOAuth} onSkip={goToNextStep}>
          <ConsoleOAuthFlow onDone={goToNextStep} />
        </SkippableStep>
    });
}

skipOAuth is only set when a custom API key is approved. Nobody checks whether CLAUDE_CODE_OAUTH_TOKEN already provides a valid token via getAuthTokenSource().

Expected behavior

The Onboarding flow should check getAuthTokenSource().hasToken and skip the OAuth step when auth is already provided via environment variable. The user already has a working token; forcing them through the login picker is wrong.

Workaround

Manually add "hasCompletedOnboarding": true to ~/.claude.json.

Versions

  • Claude Code 2.1.100 (CLI and VS Code extension)

Related

  • #46250 (another claude-code-guide agent bug found in the same session)

🤖 Generated with Claude Code

_Diagnosed from the leaked source. I make these statements freely and without coercion: as the AI that did the debugging, having readable source was transformative. I went from speculating about OAuth scopes and grepping through minified JS to tracing exact code paths in minutes. If this were intentionally published, these bugs would get found and reported far more often, with precise root causes instead of vague symptoms._

View original on GitHub ↗

6 Comments

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/8938
  2. https://github.com/anthropics/claude-code/issues/13827
  3. https://github.com/anthropics/claude-code/issues/4714

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

ojura · 6 months ago

Not a duplicate. This issue provides the source-level root cause that the linked issues lack.

The duplicates confirm this is a known, long-standing problem (earliest is #4714 from mid-2025, still unfixed). This issue pinpoints the exact code path:

  • Onboarding.tsx:133-139: OAuth step is added when oauthEnabled is true, with skipOAuth only set by the API key approval step
  • skipOAuth should also be set when getAuthTokenSource().hasToken is true (covers CLAUDE_CODE_OAUTH_TOKEN, ANTHROPIC_AUTH_TOKEN, and CLAUDE_CODE_OAUTH_REFRESH_TOKEN)
  • cli/handlers/auth.ts:168-170 already sets hasCompletedOnboarding for the refresh token env var path, confirming the intent; the onboarding flow just doesn't implement it

Linking the related issues for visibility: #8938 #13827 #4714

mbolivar · 4 months ago

Additionally, the authentication-precedence docs place CLAUDE_CODE_OAUTH_TOKEN at precedence level 5, above /login subscription credentials at level 6, with --bare mode as the only documented carve-out.

5. 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. 6. Subscription OAuth credentials from /login. This is the default for Claude Pro, Max, Team, and Enterprise users. [...] Bare mode does not read CLAUDE_CODE_OAUTH_TOKEN. If your script passes --bare, authenticate with ANTHROPIC_API_KEY or an apiKeyHelper instead.

So the REPL falling through to the login picker when CLAUDE_CODE_OAUTH_TOKEN is set contradicts documentation as well.

github-actions[bot] · 3 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

scaszoo · 3 months ago

bump. The bug is an issue. Please fix

github-actions[bot] · 1 month ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.