[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_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗