[BUG] [BUG] OAuth login succeeds but .credentials.json never written on Windows, causing permanent 401 loop

Resolved 💬 2 comments Opened Jun 26, 2026 by vsurveyor Closed Jun 30, 2026

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?

OAuth login completes successfully but .credentials.json is never written to disk, causing a permanent 401 loop that cannot be resolved through normal /login or /logout commands.

Environment

  • OS: Windows
  • Claude Code version: 2.1.195
  • Shell: PowerShell
  • Authentication method: Claude.ai subscription (Pro)

What happened?

Claude Code worked perfectly for 5 months. After ~1 week of inactivity (token expiry), it started returning:
Please run /login
API Error: 401 Invalid bearer token

Key finding:

The OAuth login flow completes without error but .credentials.json is never written to disk. Manual write permissions to C:\Users\<user>\.claude\ are confirmed working. The folder exists and contains other Claude Code files normally.

Troubleshooting already attempted:

  • Ran /logout then /login — no effect
  • Deleted $env:USERPROFILE\.claude and $env:APPDATA\Claude — no effect
  • Ran PowerShell as Administrator — no effect
  • Set CLAUDE_CODE_OAUTH_TOKEN environment variable — no effect
  • Ran claude update — already on latest version (2.1.195)
  • Tried claude --model claude-sonnet-4-6 — no effect

Expected behavior:
After successful browser authentication, .credentials.json should be written to C:\Users\<user>\.claude\ and Claude Code should authenticate normally.

Actual behavior:
.credentials.json is never created. Every command returns 401 and prompts to run /login again, creating an unresolvable loop.

What Should Happen?

Expected a normal Claude code session

Error Messages/Logs

Please run /login
API Error: 401 Invalid bearer token

Steps to Reproduce

Steps to reproduce:

  1. Leave Claude Code unused for ~1 week so OAuth token expires
  2. Run claude — get 401 error
  3. Run claude login — browser opens, authentication appears to succeed
  4. Claude Code still returns 401 immediately after
  5. Check $env:USERPROFILE\.claude\.credentials.json — file does not exist

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.195

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗