Skip to content

[BUG] VS Code Extension OAuth Auth Loop on Windows — Extension Repeatedly Loses Authentication Despite Successful Browser Authorization #33122

Description

@Sanaullah-Aasi

Preflight Checklist

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

What's Wrong?

The VS Code extension graphical panel repeatedly shows the login screen ("How do you want to log in?") every time a message is typed, even after successfully completing the full OAuth browser flow multiple times.
The browser auth does succeed — the page shows "Build something great. You're all set up for Claude Code." — but the extension panel either:

Goes completely black after the auth code is pasted back, or
Reloads back to the login screen after a VS Code window reload

Meanwhile, the CLI in the terminal retains auth (shows "Welcome back!" and API Usage Billing) but is stuck on API Usage Billing mode instead of the Pro subscription, suggesting credentials written by the terminal and extension are conflicting.

What Should Happen?

After successfully completing the OAuth browser flow and pasting the auth code:

The extension panel should load Claude Code with the Pro subscription active
Auth should persist across VS Code reloads and sessions
The extension and CLI should share or at least not conflict with each other's credential storage

Error Messages/Logs

Login
OAuth error: timeout of 15000ms exceeded
Press Enter to retry.
Esc to cancel
Terminal /status output:
Version: 2.1.71
Auth token: ANTHROPIC_AUTH_TOKEN
Model: Default (claude-sonnet-4-6)
IDE: Connected to Visual Studio Code extension
Header reads: Sonnet 4.6 · API Usage Billing — should show Pro plan.
Browser auth success: Page shows "Build something great. You're all set up for Claude Code." — confirming OAuth itself succeeds on the browser side.

Root Cause Hypothesis
Based on related issues (#29029, #22602, #8385), this appears to be caused by:

~/.claude.json overwrite conflict: The extension rewrites ~/.claude.json on every interaction, stripping auth fields written by the CLI (and vice versa), causing credentials to be wiped in a loop.
OAuth callback localhost timeout on Windows: The local server that receives the OAuth callback is blocked by Windows Firewall or antivirus before the 15-second timeout, so the CLI never receives the token even when the browser auth succeeds.
Extension and CLI using separate/conflicting credential storage: Auth completed via the extension panel is not being persisted to the same location that the CLI reads, and the extension's own storage is being cleared on reload.


Related Issues

#29029 — VS Code extension overwrites ~/.claude.json, forcing CLI onboarding on every launch
#22602 — VS Code Extension: Expired OAuth token reused across windows without refresh
#8385 — VSCode plugin doesn't remain authenticated across chats
#14023 — I am not able to login through VSCode extension
#20756 — OAuth Authentication Broken in WSL2
#6572 — API Error (request timed out) in Claude Code in VSCode


Workarounds Attempted (All Failed)

 /logout then /login in terminal
 Manually copying OAuth URL (pressing c) and pasting code back
 Reloading VS Code window after auth
 Closing and fully reopening VS Code
 Clicking "Claude.ai Subscription" button in extension panel multiple times
 Using PowerShell terminal instead of Node terminal

Steps to Reproduce

Open VS Code on Windows 11
Open the Claude Code extension panel (graphical chat view)
Type any message — the login screen appears ("How do you want to log in?")
Click "Claude.ai Subscription" (orange button)
Browser opens — press c to copy the OAuth URL manually (auto-redirect times out with OAuth error: timeout of 15000ms exceeded)
Paste URL into browser manually, log in, click Authorize
Browser shows "Build something great. You're all set up for Claude Code."
A code/token is shown — copy it and paste into the extension panel
Extension panel goes black / blank
Reload VS Code window (Ctrl+Shift+P → "Developer: Reload Window")
Type any message in the extension panel again
Login screen reappears — back to step 3

This loop repeats infinitely regardless of how many times auth is completed.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

v2.1.71

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

Additional Context

Account is confirmed active Claude Pro subscriber
Internet connectivity is working normally
Issue is 100% reproducible on every VS Code session
The CLI in terminal works for basic interactions but is incorrectly using API billing mode instead of Pro subscription

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:authbugSomething isn't workinghas reproHas detailed reproduction stepsplatform:vscodeIssue specifically occurs in VS Codeplatform:windowsIssue specifically occurs on Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions