[BUG] Claude Code OAuth authentication fails in proxy environment (Remote Development)

Status Fixed / completed
Maintainer reply None cached
Activity 6 comments · opened Nov 12, 2025 · closed Dec 30, 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?

  1. OAuth code submission appears successful: Login successful
  2. Tokens are saved to secure storage: Saving OAuth tokens to secure storage
  3. However, subscription fetch fails: Failed to fetch subscription: AxiosError: Request failed with status code 401
  4. All subsequent API calls fail with:
   Error: Could not resolve authentication method. Expected either apiKey or authToken to be set.

What Should Happen?

  • OAuth login should complete successfully
  • Extension should be able to make API calls using the obtained tokens

Error Messages/Logs

2025-11-12 13:48:55.394 [info] Handling manual auth code input
2025-11-12 13:48:56.740 [error] Failed to fetch subscription: AxiosError: Request failed with status code 401
2025-11-12 13:48:56.741 [info] Saving OAuth tokens to secure storage
2025-11-12 13:48:56.741 [info] Login successful
2025-11-12 13:48:56.741 [info] Getting authentication status
2025-11-12 13:48:56.741 [info] OAuth tokens found in secure storage
2025-11-12 13:48:56.741 [info] Auth status: method=claudeai

2025-11-12 13:49:05.629 [info] From claude: [ERROR] Error streaming, falling back to non-streaming mode: Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted

2025-11-12 13:49:05.644 [info] From claude: [ERROR] Error in non-streaming fallback: Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted

Steps to Reproduce

  1. Install Claude Code extension v2.0.37 in VS Code
  2. Connect to remote Linux server via Remote-SSH
  3. Environment has proxy configured:
   https_proxy=10.109.31.28:3128
  1. Open Claude Code and attempt to login using "Sign in with Claude.ai"
  2. Complete OAuth flow in browser
  3. Submit OAuth code in VS Code

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

None

Claude Code Version

2.0.37

Platform

Anthropic API

Operating System

Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

Environment
  • OS: Rocky Linux 9.4 (Remote Development)
  • VS Code Version: Remote SSH
  • Claude Code Extension Version: 2.0.37
  • Network: Behind corporate proxy (10.109.31.28:3128)
  • Development Environment: Remote development via VS Code Remote-SSH from Windows 11
Description

Claude Code extension fails to authenticate using OAuth (claudeai) method when working in a remote development environment with a corporate proxy. The OAuth flow appears to complete, but all subsequent API calls fail with authentication errors.

Network Connectivity Test

API endpoint is reachable through the proxy:

$ curl -v https://api.anthropic.com/v1/messages \
  -H "content-type: application/json" \
  -H "x-api-key: test"

* Uses proxy env variable https_proxy == '10.109.31.28:3128'
* Connected to 10.109.31.28 (10.109.31.28) port 3128 (#0)
< HTTP/1.1 200 Connection established
< HTTP/2 405 
# ... (Connection successful, returns expected 405 Method Not Allowed for GET)
Analysis

The issue appears to be that:

  1. OAuth tokens are successfully obtained and stored
  2. However, when the extension tries to use these tokens, they are either:
  • Not properly retrieved from secure storage in remote environment
  • Not correctly passed to the API client
  • Invalid/expired before being used
  1. The proxy environment may be interfering with the OAuth token exchange or validation process
Additional Context
  • Remote development environments may have limited secure storage capabilities
  • VS Code Remote-SSH proxy settings might not be properly inherited by the extension
  • The extension should respect both VS Code's http.proxy setting and system environment variables (HTTP_PROXY, HTTPS_PROXY)

View original on GitHub ↗

6 Comments

senolsun · 9 months ago

i have the same issue

valboosky · 9 months ago
i have the same issue

Found a workaround? My token expired and I can't get a new one in proxy environment

JuanCS-Dev · 9 months ago

Duplicate of #12353 - OAuth Proxy Corporate

This is the same issue as #12353 which I already analyzed in detail.

Root cause: OAuth callback server doesn't respect $HTTPS_PROXY environment variable.

See my full analysis here:
https://github.com/anthropics/claude-code/issues/12353#issuecomment-3575422068

Quick Summary

Problem: OAuth login fails behind corporate proxies while API calls work.

Immediate workaround: Use API key instead of OAuth

export ANTHROPIC_API_KEY="sk-ant-..."
claude

Proper fix: OAuth callback server needs to use proxy agent:

const proxyAgent = new HttpsProxyAgent(process.env.HTTPS_PROXY);
authServer.setAgent(proxyAgent);

Why API works but OAuth doesn't: Different HTTP clients, only API client respects proxy.

---

Suggest closing this as duplicate of #12353 to consolidate discussion.

github-actions[bot] · 8 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

arkadiuszkulpa · 8 months ago

Still occuring for me. I am using Dev Containers locally and the workaround is to reload and open locally then rebuild and openin container again and suddenly its all logged in and working.

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