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

Open 💬 18 comments Opened Mar 11, 2026 by Sanaullah-Aasi

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?

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

View original on GitHub ↗

18 Comments

github-actions[bot] · 4 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/14023
  2. https://github.com/anthropics/claude-code/issues/28074
  3. https://github.com/anthropics/claude-code/issues/31124

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

laniakea001 · 4 months ago

This OAuth loop issue is a known pain point. Based on the symptoms (CLI works, extension doesn't, ~/.claude.json conflict), here's a more robust solution:

Root cause: The extension and CLI write to the same config file without coordination, causing a race condition.

Solution approaches:

  1. Isolated config paths: Extension should use ~/.claude/extensions/auth.json separate from CLI's ~/.claude.json
  2. File locking: Use flock or similar to prevent concurrent writes
  3. Event-based sync: CLI broadcasts auth changes via filesystem watcher or IPC

Immediate workaround: Create a backup of your auth tokens before using the extension:

cp ~/.claude.json ~/.claude.json.backup

Then restore after extension overwrites it:

cp ~/.claude.json.backup ~/.claude.json

Long-term: This seems like a design issue worth fixing in the extension — separating credential storage from config storage would eliminate the conflict entirely.

Sanaullah-Aasi · 4 months ago

Thanks for the detailed breakdown! The race condition theory makes sense given what I'm seeing — the extension seems to be wiping auth on every reload.
I tried the backup/restore workaround:
cp ~/.claude.json ~/.claude.json.backup
But on Windows the path is C:\Users\<name>\.claude.json — for anyone on Windows the equivalent is:
copy %USERPROFILE%\.claude.json %USERPROFILE%\.claude.json.backup
And to restore:
copy %USERPROFILE%\.claude.json.backup %USERPROFILE%\.claude.json
Will test this and report back. The isolated config path suggestion (+1 on this) — having the extension use a separate auth file from the CLI would cleanly solve this without any locking complexity. Would love to see this prioritized given how many duplicates this issue has.

alkanen · 4 months ago
This OAuth loop issue is a known pain point. Based on the symptoms (CLI works, extension doesn't, ~/.claude.json conflict), here's a more robust solution: Root cause: The extension and CLI write to the same config file without coordination, causing a race condition. Solution approaches: 1. Isolated config paths: Extension should use ~/.claude/extensions/auth.json separate from CLI's ~/.claude.json 2. File locking: Use flock or similar to prevent concurrent writes 3. Event-based sync: CLI broadcasts auth changes via filesystem watcher or IPC Immediate workaround: Create a backup of your auth tokens before using the extension: cp ~/.claude.json ~/.claude.json.backup Then restore after extension overwrites it: cp ~/.claude.json.backup ~/.claude.json Long-term: This seems like a design issue worth fixing in the extension — separating credential storage from config storage would eliminate the conflict entirely.

CLI doesn't work either anymore. I got automatically logged out in the middle of a response from Claude and when I run /login I get the address to the website, it takes FOREVER for the page to actually give me a new token and when I paste the token into the CLI tool it again takes forever and finally it responds with the 15000ms timeout error.

There's an entire reddit thread about this issue started about an hour ago, so it seems like it's a server-side issue.

(the thread in question, in case you want to ask users to provide more feedback or test things: https://www.reddit.com/r/ClaudeCode/comments/1rqvio7/login_timing_out/)

acardielf · 4 months ago

Same issue on Fedora and Claude Code 2.1.72. Imposible to login

starkindustries · 4 months ago

I'm also seeing this same issue on MacOS using claude code CLI in iterm2. This is the first result that pops up when I google the error: "Claude code OAuth error: timeout of 15000ms exceeded". From what I've noticed, it seems like the oauth endpoint https://claude.ai/oauth/authorize takes forever to load, much longer than this 15000ms timeout.

Mali-Salmon · 4 months ago

Same on windows

TimZander · 4 months ago

experiencing this on windows in claude code console app now

anxuanzi · 4 months ago

same

luckydonald · 4 months ago

Seems to be a general problem of auth being down: https://isdown.app/status/claude-ai/incidents/552629-elevated-errors-on-claude-ai

<img width="890" height="408" alt="Image" src="https://github.com/user-attachments/assets/deca0fd4-076f-4303-8183-9ec475013b44" />

---

» Link to Official incident page

jvillarreal-nss · 4 months ago

At least I'm not the only one having this problem

luckydonald · 4 months ago

Changing timeout:15000timeout:45000, and
AbortSignal.timeout(15000)AbortSignal.timeout(45000)
seems to be a workaround for the slow login servers.

Either edit cli.js inside your node_modules\@anthropic-ai\claude-code\, (Source)

Or if it's a binary (e.g. install script under linux), run

cp -f "$(which claude)" "${HOME}/claude-bin.bak" && sed -i -e 's/timeout:15000/timeout:45000/g' -e 's/AbortSignal\.timeout(15000)/AbortSignal.timeout(45000)/g' "$(which claude)"
Restore with ``shell cp -f "${HOME}/claude-bin.bak" "$(which claude)" ``

Too bad that's not a simple setting.

_Give me a ⬆️ on the reddit post if this helped you._

fusion94 · 4 months ago

remind me again why I'm paying you guys $200 a month (personal account) and at work it's like 200k a month?

grahamslam · 4 months ago

I just renamed the lock file in windows environment: ..users/YOU/.claude/ide and it worked instantly. Could be coincidence that they fixed it as soon as I changed the name of the lock file, but i'm back in.

luckydonald · 4 months ago

The incident ticket was marked as resolved. Probably they vibecoded something wrong.

brian-tasa · 4 months ago

VS Code Auth working now!

Sanaullah-Aasi · 4 months ago
VS Code Auth working now!

nope its still same issue with mine setup

Sanaullah-Aasi · 4 months ago

Update: I finally resolved this issue on my end! For anyone still stuck in this infinite authentication loop, or experiencing the bug where Claude suddenly loses authentication and acts like you are not logged in, the root cause isn't necessarily a race condition or a server timeout. It is an Environment Variable conflict.

If you have an Anthropic API key saved in your Windows environment variables (even an old one), the VS Code extension and the CLI will silently prioritize it over your Claude Pro OAuth token. This causes a constant mismatch between the API Billing system and the Pro Subscription system, forcing the extension to constantly drop your session and throw you back to the "How do you want to log in?" screen.

Here is the step-by-step fix that stopped the random logouts and fixed the loop for me:

Step 1: Delete the conflicting Environment Variables
You must remove the hidden API key so Claude Code is forced to use your Pro subscription. Open PowerShell as Administrator and run:

PowerShell
[Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", $null, "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", $null, "Machine")
$env:ANTHROPIC_API_KEY=""
(Alternatively, you can manually delete ANTHROPIC_API_KEY via the Windows "Edit the system environment variables" menu).

Step 2: Wipe the corrupted config files
Run this in PowerShell to clear out the broken, conflicting session data:

PowerShell
Remove-Item -Path "$env:USERPROFILE\.claude.json" -Force -ErrorAction SilentlyContinue
Remove-Item -Path "$env:USERPROFILE\.claude" -Recurse -Force -ErrorAction SilentlyContinue
Step 3: The crucial restart

Completely close VS Code. (This is mandatory, as VS Code holds onto old environment variables in memory until a full restart).

Open a fresh terminal and run claude.

Complete the OAuth flow in the browser.

Check the terminal header—it should now correctly say Pro subscription instead of API Usage Billing.

Once I wiped those variables and restarted, the VS Code extension immediately recognized my Pro auth, the random logouts stopped, and the infinite loop was fixed. Hopefully, this helps anyone else who has old API keys lingering on their system!