[BUG] Authentication Loop: API Key Ignored, OAuth Repeatedly Fails, Making Claude Code Unusable

Status Fixed / completed
Maintainer reply None cached
Activity 5 comments · opened Sep 18, 2025 · closed Sep 22, 2025

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_

View original on GitHub ↗

5 Comments

github-actions[bot] · 1 year ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/5767
  2. https://github.com/anthropics/claude-code/issues/6063
  3. https://github.com/anthropics/claude-code/issues/1651

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

GavBain · 1 year ago

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.

jerzydziewierz · 1 year ago

+1
why would they remove API key access????

GavBain · 1 year ago

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.

github-actions[bot] · 1 year 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.