[BUG] API Error 401 - OAuth error
Resolved 💬 16 comments Opened Mar 11, 2026 by pm0code Closed May 25, 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?
API Error: 401
{"type":"error","error":{"type":"authentication_error","message":"Invalid
authentication credentials"},"request_id":"req_011CYwVksiyBbVdDiMU5xzr7"} · Please run /login
What Should Happen?
OAuth process should finish and return the results
Error Messages/Logs
OAuth error: timeout of 15000ms exceeded
Steps to Reproduce
try to use Claude Code
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
Claude Code v2.1.72
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
_No response_
16 Comments
+1
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
+1
+1
+1
+1
try /logout and then /login again. it worked for me
Root Cause
Claude Code
v2.1.72appears to fail during the OAuth authentication flow. The CLI attempts to exchange the OAuth authorization code for an access token, but the request times out:OAuth error: timeout of 15000ms exceeded
After the timeout occurs, Claude Code proceeds without a valid token, which causes the subsequent API request to fail with:
API Error: 401
Invalid authentication credentials
This indicates the OAuth token exchange step is failing or timing out, leaving the CLI in an unauthenticated state.
---
Proposed Fix
Improve the OAuth token exchange logic by:
---
Example Patch (TypeScript)
Increase OAuth Timeout
I found a workaround for this issue. I used the binary from a previous version (2.1.50), which can be found in ~/.local/share/claude/versions. I logged in using that version, and once the authentication was successful, I was able to switch back and use the latest version (2.1.72) without any problems."
this is happening again, 6:51 pm PST :(
It is happening again:
API Error: 500 {"type":"error","error":{"type":"api_error","message":"Internal
server error"},"request_id":
Why do we as customers have to go through this over and over again? This is simply a resource allocation matter. We are paying for the service already!
@claude ^
this is back again:
Please run /login · API Error: 401
{"type":"error","error":{"type":"authentication_error","message":"OAuth token has
expired. Please obtain a new token or refresh your existing
token."},"request_id":"req_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}
OAuth error: timeout of 15000ms exceeded
We are losing critical work hours for a paid service?!?
@claude ^
From interaction with Fin (Claude Support) the following helped me:
This 401 is most likely Claude Code picking up an API key (or an old/expired credential) instead of using your Pro OAuth token.
Try this exact sequence:
Run /logout (even if it returns 401).
Run claude update.
Fully restart your terminal (quit the terminal app, reopen).
Run claude and complete the login again.
Also double-check you have no ANTHROPIC_API_KEY anywhere in your shell profile (.zshrc/.bashrc/.profile) and run unset ANTHROPIC_API_KEY before starting Claude Code, since an API key takes precedence and can cause 401s if it’s disabled/expired.
I hope this helps others!
Thanks @BrianSlatts1980. did not work.
here we go again, Monday morning and this is back again:
API Error: 500 {"type":"error","error":{"type":"api_error","message":"Internal
server error"},"request_id":"req_00000000000000000000000"}
Closing for now — inactive for too long. Please open a new issue if this is still relevant.