fix(auth): stop treating CLAUDE_CODE_OAUTH_TOKEN as Anthropic API key#19260
fix(auth): stop treating CLAUDE_CODE_OAUTH_TOKEN as Anthropic API key#19260alanxchen85 wants to merge 1 commit into
Conversation
CLAUDE_CODE_OAUTH_TOKEN is an OAuth token scoped to Claude Code. When Hermes runs in the same environment as Claude Code (common on dev machines), it picks up this token and tries to use it for Anthropic API requests. The Anthropic API rejects it with HTTP 400 because the token is bound to Claude Code's OAuth client, not Hermes. This causes silent auth failures or crash loops when the user has Claude Code installed but hasn't explicitly configured Anthropic credentials for Hermes. Remove CLAUDE_CODE_OAUTH_TOKEN from: - auth.py: Anthropic provider api_key_env_vars - providers.py: Anthropic HermesOverlay extra_env_vars - web_server.py: auth status endpoint fallback The token is already in the terminal subprocess blocklist (local.py) and marked as implicit in setup.py, so this completes the separation. Users who want Anthropic access in Hermes should set ANTHROPIC_API_KEY explicitly. Fixes #15080
|
Thanks for the PR. Closing — picking up Your bug report (HTTP 400) suggests the OAuth handling didn't work for your specific scenario — that's worth investigating, but the fix isn't to drop the pickup entirely. Could you file an issue with the exact error body and the token prefix ( |
Summary
CLAUDE_CODE_OAUTH_TOKENfrom Anthropic provider'sapi_key_env_varsinauth.pyextra_env_varsinproviders.pyweb_server.pyProblem
When Hermes runs alongside Claude Code (common on dev machines), it picks up
CLAUDE_CODE_OAUTH_TOKENand tries to use it for Anthropic API requests. The token is an OAuth token scoped to Claude Code's client ID — the Anthropic API rejects it with HTTP 400. This causes silent auth failures or crash loops.The token is already blocked from terminal subprocesses (
local.pyline 53) and marked as implicit insetup.py, but the auth resolver still treats it as a valid API key.Fix
Remove
CLAUDE_CODE_OAUTH_TOKENfrom the three places that use it as an Anthropic credential. Users who want Anthropic access in Hermes should setANTHROPIC_API_KEYexplicitly.Test plan
CLAUDE_CODE_OAUTH_TOKENis presenthermes setupstill prompts for Anthropic API key correctlyANTHROPIC_API_KEYstill works as beforeFixes #15080
🤖 Generated with Claude Code