Skip to content
This repository was archived by the owner on Feb 18, 2026. It is now read-only.
This repository was archived by the owner on Feb 18, 2026. It is now read-only.

[BUG] Claude Code Max OAuth credentials rejected - missing identifying headers #7

@shekohex

Description

@shekohex

Bug Report

Claude Code Max OAuth authentication fails with error: "This credential is only authorized for use with Claude Code and cannot be used for other API requests."

Environment

  • claude-code-mux version: latest (commit f3f5fd7)
  • Provider: Anthropic (OAuth - Claude Code Max)
  • OAuth token: Successfully loaded and valid

Reproduction

  1. Authenticate via OAuth using Claude Code Max subscription
  2. Configure provider with auth_type = "oauth" and oauth_provider = "anthropic-max"
  3. Make API request to Claude model
  4. Observe error from Anthropic API

Logs

2025-11-19T22:45:39.235367Z  INFO ccm::server: Loaded 1 OAuth tokens from storage
2025-11-19T22:45:52.898872Z  INFO ccm::server: Found 2 provider mappings for model: claude-sonnet-4.5
2025-11-19T22:45:52.898876Z  INFO ccm::server: Trying mapping 1/2: provider=claude-max-main, actual_model=claude-sonnet-4-5-20250929
2025-11-19T22:45:53.304162Z  INFO ccm::server: Provider claude-max-main failed: Provider API error: 400 - claude-max-main API error: {"type":"error","error":{"type":"invalid_request_error","message":"This credential is only authorized for use with Claude Code and cannot be used for other API requests."},"request_id":"req_011CVJ4RtkjqxsfEdexwMoZR"}, trying next fallback

Current Implementation

File: src/providers/anthropic_compatible.rs (lines 215-219)

OAuth requests currently send:

  • Authorization: Bearer {access_token}
  • anthropic-version: 2023-06-01
  • anthropic-beta: oauth-2025-04-20,claude-code-20250219,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14
  • Content-Type: application/json

According to analysis of the official opencode-anthropic-auth package, these headers are correct and match the official implementation.

Possible Causes

Since headers are correct, the issue must be:

  1. Request body format - CCM might be sending incorrect request body structure
  2. Endpoint URL - Verify endpoint is exactly https://api.anthropic.com/v1/messages
  3. OAuth token issues - Token might not have correct scopes or might be acquired differently
  4. Request transformation - Something in the Anthropic→Claude translation might be incompatible

Alternative Solution: create_api_key Flow

The codebase includes a create_api_key method (src/auth/oauth.rs line 533) that creates an API key from the OAuth token:

pub async fn create_api_key(&self, provider_id: &str) -> Result<String> {
    let access_token = self.get_valid_token(provider_id).await?;
    
    let response = self.http_client
        .post("https://api.anthropic.com/api/oauth/claude_cli/create_api_key")
        .header("Content-Type", "application/json")
        .header("Authorization", format!("Bearer {}", access_token))
        // ...
}

This method exists but is never called. The official OpenCode implementation offers this as an alternative authentication method labeled "Create an API Key".

Possible workaround:

  1. On OAuth token acquisition, call create_api_key() to get an API key
  2. Store the API key alongside the OAuth token
  3. Use the API key for API requests instead of the OAuth token
  4. Refresh API key when OAuth token is refreshed

Additional Context

README claims Claude Code Max is supported:

Yes! Claude Code Mux supports OAuth 2.0 authentication for all three providers:

  • Claude Pro/Max: Providers tab → Add Provider → Select "Anthropic" → Choose "OAuth (Claude Pro/Max)"

The OAuth scopes include org:create_api_key, which suggests the create_api_key flow might be the intended approach.

References

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions