[BUG] Authentication Loop: API Key Ignored, OAuth Repeatedly Fails, Making Claude Code Unusable
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?
Authentication Loop: API Key Ignored, OAuth Repeatedly Fails, Making Claude Code Unusable
Body:
Environment:
OS: Windows 11 with WSL2 (Ubuntu)
Claude Code Version: 1.0.117
Node.js: v22.19.0
Installation Method: npm global install
Issue Summary:
Fresh installation of Claude Code results in persistent authentication failures, making the tool completely unusable. Multiple authentication methods attempted, all fail with different issues.
Steps to Reproduce:
Fresh install: npm install -g @anthropic-ai/claude-code
Run claude in project directory
Attempt any AI request (e.g., "what files are in this directory?")
Observed Behavior:
Phase 1 - OAuth Authentication:
Initial OAuth login appears successful
All AI requests result in "API Error (Request timed out)" after multiple retry attempts
/status and /help commands work fine
Basic commands like pwd also timeout (incorrectly sent to API instead of executed locally)
Phase 2 - API Key Authentication:
Set ANTHROPIC_API_KEY environment variable with valid API key (verified working via direct curl)
Claude Code detects API key but still forces OAuth browser authentication
Shows "Auth conflict" warning but ignores the API key
Gets stuck in authentication loops, repeatedly prompting for browser OAuth despite API key being present
Direct API test successful: curl -X POST https://api.anthropic.com/v1/messages returns proper auth error (not timeout)
Internet connectivity confirmed working
No corporate firewall/VPN issues
Additional Context:
This affects basic usability - a simple "hello world" level test becomes impossible due to authentication system failures. The tool appears to have fundamental issues with both authentication methods.
What Should Happen?
With valid API key set, should skip OAuth entirely
AI requests should complete without timeouts
Basic commands shouldn't be sent to API
Error Messages/Logs
Steps to Reproduce
It occurs on a clean install.
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
1.0.117
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_
5 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Although login reports as successful, neither login method results in a working environment. Even the very simplest of commands executed in a test directory with a single 4 line .js file for testing purposes, results in API timeout messages.
<img width="703" height="501" alt="Image" src="https://github.com/user-attachments/assets/32700a9d-48b0-4072-9044-f40e12649c50" />
Diagnostics
└ Currently running: npm-global (1.0.117)
└ Path: /home/gavin/.nvm/versions/node/v22.19.0/bin/node
└ Invoked: /home/gavin/.nvm/versions/node/v22.19.0/bin/claude
└ Config install method: global
└ Auto-updates enabled: default (true)
└ Update permissions: Yes
└ Search: OK (vendor)
Uninstalled via NPM, cleared caches and setup files and a fresh install brings me back to the same broken state.
The environment is unusable in this state.
+1
why would they remove API key access????
Revisited the same test setup after a few days and it now works correctly. I assume there was an API issue that has not been resolved.
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.