[BUG] Failed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid authentication credentials"},"request_id":"xxxxxxxxx"}
Status Closed — not planned
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 10 comments · opened Apr 15, 2026 · closed Jun 12, 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?
Trying to send a prompt through VS Code Claude plugin, I get the Failed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid authentication credentials"},"request_id":"xxxxxxxxxxxxxx"} error and a "Authenticate" page opens, but following the link "Authenticate with subscription" triggers an URL that does nothing. All development blocked.
What Should Happen?
Authentication shouldn't be required or the "authenticate" feature should work.
Error Messages/Logs
Steps to Reproduce
Just write a prompt into VS Code throuth the Claude plugin.
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
-
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_
10 Comments
The 401 with an "Authenticate" link that does nothing is a broken auth recovery flow — the error is real (credentials are invalid) but the recovery mechanism is broken (the auth URL does not complete the flow).
From an agent identity perspective this surfaces a gap in the Claude Code auth model: credential validity and session identity are conflated. When credentials expire or become invalid, the session identity (which work, which conversation, which agent context) is lost along with the credentials. The user is sent back to square zero — not just re-authenticated, but starting a completely fresh session.
A better recovery model:
1. Re-authentication that preserves session identity. When credentials expire mid-session, the re-auth flow should confirm the user is the same identity as the session owner, then restore the session state rather than creating a fresh one. This requires the session to be bound to a stable identity (not just a credential token).
2. Graceful 401 surfacing in VS Code panel. Rather than a broken "Authenticate" link that opens nothing, the 401 should surface as an in-panel action: "Click to re-authenticate" that opens the auth flow inline or in a dedicated browser tab with a clear redirect back to VS Code. The current behavior suggests the auth URL is correct but the OAuth redirect is not wired to the VS Code extension handler.
For a practical workaround while the fix lands: sign out completely from the Claude Code extension settings, clear any cached credentials, then sign in fresh. The 401 with broken recovery is often caused by a stale partial auth state.
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Outage, check: https://status.claude.com/
Im also facing the same issue in Claude code.
Failed to authenticate. API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid authentication credentials"},"request_id":"xxxxxxxxxxxxx"}
Unable to work on any new Claude code session too.
OAuthError: Unable to start session. Check your internet connection and try again
Internet is working fine. No VPN. Chat is working fine.
Claude code and cowork is not working. I was casually working on the Claude code session, suddenly it stopped working. I tried re authenticating. it's not working. Please help on this. Thanks.
<img alt="Image" src="https://github.com/user-attachments/assets/eb87221d-df10-4659-ad2c-0a9690c11804" />
Update: It worked fine after restarting my Mac. Thanks.
Failed to authenticate - API Error 401 Invalid bearer token ## Problem
Cowork fails to authenticate with the Claude API showing a 401 error.
Error message
Failed to authenticate.
API Error: 401
{"type":"error","error":{"type":"authentication_error",
"message":"Invalid bearer token"},"request_id":"req_011xxxxxxxxxxxxxxx"}
Steps taken
Environment
Question
Is there a configuration step needed to set up the API key?
Or is this a known issue with the current version?
Any workaround found for this? this just started happening to me 100% of the time on one of my win11 machines. same account works fine from a different machine.
In a new profile the error disappears. What you need to do is completely remove all registry entries and orphaned files in Windows, uninstall the application, and restart the computer. After that, you’ll be able to install it again and Cowork will work properly.
Regards
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
I had the same issue and I followed below steps and finally worked.
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.