API Key Authentication Fails in code-server Environment

Resolved 💬 3 comments Opened Oct 27, 2025 by bzeeman Closed Oct 30, 2025

Bug Report:

API Key Authentication Fails in code-server Environment

### Environment

  • Extension Version: 2.0.27
  • Platform: code-server add-on on Home Assistant OS
  • Node.js Version: (installed via code-server add-on packages

configuration)

  • Authentication Method: Pay-as-you-go API key

### Description
Claude Code extension successfully initializes and reports finding the API
key in the config file, but fails to pass the API key to the Anthropic
SDK when making actual API calls.

### Steps to Reproduce

  1. Install code-server add-on on Home Assistant OS
  2. Add Node.js via add-on configuration:

```yaml
packages:

  • nodejs
  • npm

```

  1. Install Claude Code extension in code-server
  2. Run /login with pay-as-you-go account
  3. Complete OAuth flow and paste authorization token
  4. Attempt to send a message to Claude

### Expected Behavior
Claude Code should make successful API calls using the authenticated API
key.

### Actual Behavior
Extension logs show successful authentication:
``
[info] API key found in config file
[info] Auth status: method=api-key
``

But API calls fail with:
``
[ERROR] 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
at uy.validateHeaders (file:///data/vscode/extensions/anthropic.claude
-code-2.0.27-universal/resources/claude-code/cli.js:357:930)
at uy.buildHeaders (file:///data/vscode/extensions/anthropic.claude-co
de-2.0.27-universal/resources/claude-code/cli.js:357:8412)
``

### Additional Context

  • The config file at ~/.claude/config.json contains a valid API key

with correct structure:
``json
{
"primaryApiKey": "sk-ant-api03-...",
"customApiKeyResponses": {
"approved": ["..."]
}
}
``

  • The extension successfully reads this file during initialization
  • The API key is valid (can be verified via direct curl to

api.anthropic.com)

  • Issue appears to be in how the API key is passed from the extension to

the CLI process in code-server environments

### Related Information

  • Previously worked with Claude Pro (OAuth token-based auth)
  • After attempting to switch to pay-as-you-go (API key-based auth), both

methods stopped working

  • Required clearing all cached auth state and reinstalling to get even

login flow working again

  • Suggests the API key code path may have issues in code-server

environments that the OAuth token path doesn't have

### Full Log Output
``
2025-10-26 23:42:25.714 [info] API key found in config file
2025-10-26 23:42:25.714 [info] Auth status: method=api-key
...
2025-10-26 23:42:27.728 [info] From claude: [ERROR] "Error: Error: 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
``

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗