[BUG] Claude Code 401 Authentication Error on Windows
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:
- Install Claude Code v2.1.49 (native) on Windows:
irm https://claude.ai/install.ps1 | iex
- Launch Claude Code:
claude
Run login command:
- /login
Complete OAuth flow in browser (shows "Login successful")
- Press Enter to continue
- 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
4 Comments
Found 2 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
None of these issues are related
These issues found are not related to the Auth file at $env:USERPROFILE.config\claude-code\auth.json not existing after successful login
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.