[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
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_

View original on GitHub ↗

10 Comments

0xbrainkid · 6 months ago

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.

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/14023
  2. https://github.com/anthropics/claude-code/issues/43715
  3. https://github.com/anthropics/claude-code/issues/44253

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

sefinek · 6 months ago
Balaviknesh · 5 months ago

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.

wrxcharger · 5 months ago

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

  • Checked Windows 10 Firewall - no rules blocking Cowork
  • Checked McAfee Firewall - no blocking rules found
  • Firewall does not appear to be the cause

Environment

  • OS: Windows 10
  • Antivirus: McAfee
  • Desktop: [Claude 1.3883.0 (93ff6c) 2026-04-21T17:24:01.000Z]

Question

Is there a configuration step needed to set up the API key?
Or is this a known issue with the current version?

stoic-john · 5 months ago

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.

wrxcharger · 5 months ago

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.

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.

Regards

github-actions[bot] · 4 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

sumithharshan · 3 months ago

I had the same issue and I followed below steps and finally worked.

  1. Update the VS code.
  2. Update the VS code Claude Extension
  3. Disable and enable Claude Extension, then Restart
  4. Close VS code
  5. Delete Claude settings.json file
  6. Open the VS code and must be worked.
github-actions[bot] · 1 month ago

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.