[BUG] Claude Code 401 Authentication Error on Windows

Resolved 💬 4 comments Opened Feb 20, 2026 by partha2010 Closed Feb 20, 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?

Environment:

Claude Code v2.1.49 (native install)
Windows
Pro subscription (active)
Issue:

/login completes successfully ("Login successful")
whoami immediately returns 401 error
Error retries repeatedly (attempt X/10)
Error message:

401 {"type":"error","error":{"type":"authentication_error","message":"login fail: Please carry the API secret key in the 'Authorization' field of the request header"},"request_id":"..."}
Troubleshooting completed:

No VPN or proxy
curl -v https://api.anthropic.com/v1/messages works correctly (reaches real Anthropic servers)
Reinstalled Claude Code (native)
Deleted ~/.claude and ~/.claude.json
Auth file at ~/.config/claude-code/auth.json does not exist after login
Conclusion:
OAuth token is not being saved or sent correctly after login. The non-standard error message format suggests a bug in how Claude Code handles authentication on Windows.

What Should Happen?

After /login completes successfully:

OAuth token should be saved to disk
whoami should return account details (user ID, email, subscription type)
Claude Code should authenticate all API requests automatically using the stored token

Error Messages/Logs

> whoami
  ⎿  401 {"type":"error","error":{"type":"authentication_error","message":"login fail: Please carry the API secret key in the 'Authorization' field of the request header"},"request_id":"05e7bceb6cb79ea0aeba2dc3424d0590"}
     Retrying in 8 seconds… (attempt 5/10)

Steps to Reproduce

Steps to Reproduce:

  1. Install Claude Code v2.1.49 (native) on Windows:

irm https://claude.ai/install.ps1 | iex

  1. Launch Claude Code:

claude
Run login command:

  1. /login

Complete OAuth flow in browser (shows "Login successful")

  1. Press Enter to continue
  1. Run whoami command:

whoami
Observe 401 authentication error with message "Please carry the API secret key in the 'Authorization' field of the request header"

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

Worked with the same setup prior to renewing the Max Plan

Claude Code Version

Claude Code v2.1.49

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

Auth file at $env:USERPROFILE\.config\claude-code\auth.json does not exist after successful login
Direct API access via curl -v https://api.anthropic.com/v1/messages works correctly
Reinstalling and clearing all auth data (~/.claude, ~/.claude.json) does not resolve the issue

View original on GitHub ↗

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