claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

claude auth login` / `claude setup-token` fail with OAuth 403 "missing user:profile scope" on Windows, while Claude Desktop login works fine

Open Necomiao opened this issue 2 months ago • 3 comments

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Claude Code CLI's OAuth login (claude auth login / claude setup-token / /login) fails with a 403 error and "missing user:profile scope", even though the browser authorization step completes successfully. Claude Desktop app on the same machine/account logs in fine, so the account itself works — the issue seems specific to the CLI's OAuth token exchange.

Full diagnostic details, steps to reproduce, and what I've already ruled out are below.

What Should Happen?

claude auth login / claude setup-token should successfully exchange the OAuth authorization for a token with the full required scopes (including user:profile), so that claude auth status reports loggedIn: true and Claude Code can be used with my Pro/Max subscription — consistent with how Claude Desktop already authenticates successfully with the same account on the same machine.

Error Messages/Logs

$ claude setup-token
You already have authentication configured via environment variable or API key helper
(request failed with) 403

$ claude
> /login
> Select: Claude account with subscription
Login
OAuth error: Request failed with status code 403

$ claude doctor
Remote Control
Remote Control requires a claude.ai subscription. Run claude auth login to sign in with your claude.ai account.
- Not signed in to claude.ai
- claude.ai subscription auth not active
- Sign-in is missing the user:profile scope

No installation issues found.

Steps to Reproduce

1. On Windows 11, install Claude Code CLI via `npm install -g @anthropic-ai/claude-code` (version 2.1.215).
2. Run `claude auth login` in PowerShell.
3. Browser opens the OAuth consent page; complete authorization — browser shows "authorization successful".
4. Back in the terminal, run `claude auth status` → reports `loggedIn: false`.
5. Run `claude setup-token` → fails with "You already have authentication configured via environment variable or API key helper", then HTTP 403.
6. Confirmed no ANTHROPIC_AUTH_TOKEN / ANTHROPIC_API_KEY / ANTHROPIC_BASE_URL / apiKeyHelper / CLAUDE_CODE_USE_BEDROCK / CLAUDE_CODE_USE_VERTEX set anywhere (process, user, machine env, settings.json, managed-settings.json) — error persists regardless.
7. Run `claude` → `/login` → select "Claude account with subscription" → immediately fails with `OAuth error: Request failed with status code 403`.
8. Run `claude doctor` → confirms "Not signed in", "Sign-in is missing the user:profile scope".
9. Claude Desktop app, installed on the same machine under the same account, logs in via OAuth successfully with no issues.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.215

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

Title

claude auth login / claude setup-token fail with OAuth 403 "missing user:profile scope" on Windows, while Claude Desktop login works fine

Environment

  • OS: Windows 11 Home (10.0.26200), x64
  • Claude Code CLI version: 2.1.215 (npm-global install, @anthropic-ai/claude-code)
  • Install path: %APPDATA%\npm\node_modules\@anthropic-ai\claude-code\bin\claude.exe
  • Node.js via npm global wrapper (claude.ps1 / claude.cmd) — verified unmodified, standard npm-generated wrapper
  • Claude Desktop app: installed and logged in successfully on the same machine/account

Steps to reproduce

  1. Run claude auth login in PowerShell
  2. Browser opens, OAuth consent page completes, browser shows "authorization successful"
  3. Back in terminal, claude auth status still reports loggedIn: false
  4. Run claude setup-token:
    • First attempt: error "You already have authentication configured via environment variable or API key helper", followed by HTTP 403
  5. Run claude → /login interactively, select "Claude account with subscription":
    • Fails immediately with: OAuth error: Request failed with status code 403

claude doctor output (relevant section)

Remote Control
Remote Control requires a claude.ai subscription. Run claude auth login to sign in with your claude.ai account.
- Not signed in to claude.ai
- claude.ai subscription auth not active
- Sign-in is missing the user:profile scope

No installation issues found.

What I've already ruled out locally

  • ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL, ANTHROPIC_MODEL, CLAUDE_CODE_USE_BEDROCK, CLAUDE_CODE_USE_VERTEX — confirmed unset at process, user (HKCU\Environment), and machine (HKLM\...\Environment) scope
  • No ~/.claude/settings.json, ~/.claude/settings.local.json, or project-level .claude/settings.json exist (so no apiKeyHelper)
  • No enterprise managed policy file at C:\ProgramData\ClaudeCode\managed-settings.json
  • claude.ps1 / claude.cmd wrapper scripts are unmodified npm-generated boilerplate (no injected env vars)
  • No Windows hosts file entries for anthropic.com / claude.ai domains
  • No stray credentials in Windows Credential Manager (cmdkey /list) related to claude/anthropic
  • System clock/timezone correct (China Standard Time, verified against actual time)
  • curl -v to https://console.anthropic.com and https://api.anthropic.com both complete TLS handshake normally with expected HTTP responses (301 redirect and 403-for-unauthenticated-GET respectively) — no certificate interception detected
  • Tested through a home-network local HTTP/SOCKS proxy (residential IP, same egress as a mobile device on the same network) — same 403 result regardless

Additional notes

  • Claude Desktop app on the same machine/account is already logged in via OAuth and works normally, suggesting the account itself can authenticate somewhere, but the standalone CLI's OAuth flow specifically cannot obtain a token with the user:profile scope.
  • I have not yet tested from a completely different network/IP (in progress).

Request

Could you help identify why the CLI-specific OAuth flow returns 403 / is missing the user:profile scope, while Desktop login for the same account succeeds? Is this likely account-side rate limiting/anti-abuse, or a client-side OAuth scope negotiation issue in 2.1.215? Happy to provide additional logs if needed (redacting secrets).

Necomiao avatar Sep 13 '26 07:09 Necomiao

The 403 matters less than where it lands, and the CLI is hiding that. Two different failures produce this symptom, and they need different next steps:

  1. The authorization server rejects the token exchange (403 from /token). The response body normally carries an OAuth error code (invalid_scope, access_denied, invalid_grant) and often names the offending scope. The CLI swallows it and prints a generic message, so the first worthwhile capture is the actual response body. A local proxy in front of the CLI, or any debug flag that prints the exchange response, splits this case immediately.
  2. The exchange succeeds, but the issued token lacks user:profile (granted scopes are a subset of requested). claude doctor detects this by reading the token, not the request, which is why it can say "missing user:profile scope" while the browser flow shows success.

For case 2, the common causes sit upstream of the token endpoint, in the authorization request that produced the code:

  • The authorization URL may not carry the full scope set. If the scope parameter is lost anywhere between the CLI and the browser (URL quoting on Windows shells is the classic: an ampersand inside a URL can truncate everything after it before the browser opens), the server issues a code for default scopes only. Every later step looks healthy while the entitlement is gone. Check what the consent page itself lists as requested scopes; fewer than expected confirms it.
  • The browser session that completed consent. The code is bound to the claude.ai account signed into the browser that opened the URL. If that browser was signed into a different account or org than the one holding the subscription, the exchange produces a token scoped to the wrong principal. A clean-profile test signed into the target account, separate from the Desktop session, is the cheap discriminator.
  • Enforcement. A 403 with no scope error in the body, on an account that authenticates fine elsewhere, is what anti-abuse enforcement looks like from the client side, and there is no client-side fix for it. The different-network test already in progress is the right probe for that branch.

On the setup-token message about existing authentication: since every relevant variable is confirmed unset at process, user, and machine scope, that line is the CLI's own precedence check tripping on something it reads internally, possibly a stale credential store outside Windows Credential Manager. Clearing stored CLI credentials and retrying in a fresh shell is worth one attempt before deeper digging.

We build on top of three dozen vendors' OAuth stacks at corpusiq.io, and the habit that pays off every time is the same: decode the token you actually received and compare granted scopes against the scope set you sent. That one step splits "server rejected us" from "server downscoped us".

Ben-Home avatar Sep 15 '26 14:09 Ben-Home

By the way, I'm getting something similar (although getting 403 not directly after /login, but on any prompt after completing it) after upgrade from .270 to .280

msva avatar Sep 24 '26 03:09 msva

Reproduced on Claude Code 2.1.281 native Windows install.

Windows x64 Install: native Path: C:\Users<user>.local\bin\claude.exe

claude doctor:

  • Not signed in to claude.ai
  • claude.ai subscription auth not active
  • Sign-in is missing the user:profile scope

claude auth login:

  • Browser authorization completes successfully: "You're all set up for Claude Code."
  • CLI then fails with: "Login failed: Request failed with status code 403"

claude auth status remains: { "loggedIn": false, "authMethod": "none", "apiProvider": "firstParty" }

The same failure occurs with both npm-global and native installations, so this does not appear to be related to the npm wrapper or PowerShell ExecutionPolicy.

DimaTurbologo avatar Sep 24 '26 17:09 DimaTurbologo

I'm experiencing the same issue on Windows with Claude Code 2.1.283 and an active Claude Pro subscription. Browser authentication completes successfully, but claude auth login fails with HTTP 403. claude doctor reports Sign-in is missing the user:profile scope. The same issue occurs with claude setup-token, the standalone native CLI, and the VS Code extension. I also tested Chrome and Opera, with identical results. claude doctor reports "No installation issues found."

gidroponix avatar Sep 27 '26 23:09 gidroponix