[BUG] CLI OAuth login succeeds but all API calls return 401 Invalid bearer token (desktop app works fine)
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?
Claude Code CLI (claude.exe) consistently fails with 401 authentication errors despite successfully completing OAuth login. The desktop app works fine with the same Claude.ai Pro account.
Steps to reproduce:
Run claude in PowerShell
Send any message → get 401
Run /login → browser opens, authenticate, "Login successful"
Send any message → still get 401
Expected behavior: OAuth login grants API access, messages succeed.
Actual behavior:
API Error: 401 {"type":"error","error":{"type":"authentication_error","message":"Invalid bearer token"}}
Environment:
Claude Code version: 2.1.121
OS: Windows 11
Installation: standalone .exe (C:\Users\matan\.local\bin\claude.exe) + npm global
Account: Claude.ai Pro, personal account
Diagnostics:
ANTHROPIC_API_KEY is not set
.credentials.json exists, has correct structure, scopes include user:sessions:claude_code, subscriptionType: "pro", token is not expired
Both fresh and cached tokens are rejected immediately
Desktop app Claude Code works fine with the same account
Request IDs:
req_011CaVsBjy8HDPXrpmYVgnid
req_011CaVsKDcERdhtT6DYXKW3C
req_011CaVtUrPvFZSWuLqQ8GiVb
req_011CaVtAwPZGNBxnjtKbVwRa
req_011CaVtVyHwDvu6wcQSB5AYZ
What Should Happen?
regular login
Error Messages/Logs
Steps to Reproduce
idk
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.121
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗