Repository navigation
Closed
Labels
P2Medium — degraded but workaround existsMedium — degraded but workaround existsarea/authAuthentication, OAuth, credential poolsAuthentication, OAuth, credential poolscomp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointprovider/anthropicAnthropic native Messages APIAnthropic native Messages APItype/bugSomething isn't workingSomething isn't working
Description
Version: v0.16.0, commit a118b94a
Symptom
Claude Pro/Max subscription login via hermes auth add anthropic --type oauth fails at the token-exchange step:
Token exchange failed: HTTP Error 404: Not Found
Anthropic OAuth login did not return credentials.
Browser authorization succeeds (a valid code#state is pasted back), but the token exchange returns 404.
Root cause
In agent/anthropic_adapter.py, the login and refresh flows disagree on the token endpoint:
- Login flow —
run_hermes_oauth_login_pure()(~line 1337) POSTs to a single hardcoded endpoint_OAUTH_TOKEN_URL = "https://console.anthropic.com/v1/oauth/token"→ 404. - Refresh flow —
refresh_anthropic_oauth_pure()(~line 994) already uses a fallback list that trieshttps://platform.claude.com/v1/oauth/tokenfirst, then the console host — and works.
The refresh path already "knows" the current host; the login path was simply not updated alongside it.
Fix
Make the login token exchange iterate the same endpoint list (platform.claude.com first), mirroring refresh_anthropic_oauth_pure():
_token_endpoints = [
"https://platform.claude.com/v1/oauth/token",
_OAUTH_TOKEN_URL, # console.anthropic.com fallback
]
result = None
last_error = None
for _endpoint in _token_endpoints:
try:
req = urllib.request.Request(
_endpoint, data=exchange_data,
headers={
"Content-Type": "application/json",
"User-Agent": f"claude-cli/{_get_claude_code_version()} (external, cli)",
},
method="POST",
)
with urllib.request.urlopen(req, timeout=15) as resp:
result = json.loads(resp.read().decode())
break
except Exception as e:
last_error = e
continue
if result is None:
print(f"Token exchange failed: {last_error}")
return NoneVerification (after patch)
hermes auth add anthropic --type oauthstores the credential (anthropic-oauth-1).hermes chat -q "Reply with exactly: OK" -m anthropic/claude-opus-4.8 --provider anthropic -QreturnsOKon the subscription (no tier rejection).
Environment
- macOS, Hermes v0.16.0 (commit a118b94), Python 3.11.15.
Metadata
Metadata
Assignees
Labels
P2Medium — degraded but workaround existsMedium — degraded but workaround existsarea/authAuthentication, OAuth, credential poolsAuthentication, OAuth, credential poolscomp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointprovider/anthropicAnthropic native Messages APIAnthropic native Messages APItype/bugSomething isn't workingSomething isn't working
Activity
liuhao1024 commentedon Jun 13, 2026
This is fixed by #45254 — fix(auth): iterate token endpoints in Anthropic OAuth login flow.
prasadus92 commentedon Jun 21, 2026
Confirmed on v0.17.0 (5aec00f). Root cause is one stale constant:
run_hermes_oauth_login_pureposts the code exchange to_OAUTH_TOKEN_URL = https://console.anthropic.com/v1/oauth/token(agent/anthropic_adapter.py:1254), which 404s. The refresh path at ~:997 was already migrated and iterates["https://platform.claude.com/v1/oauth/token", "https://console.anthropic.com/v1/oauth/token"]. The login path just needs the same list; the open PRs that do this are correct.Worth flagging for anyone here hunting a workaround: putting a
claude setup-tokenvalue inANTHROPIC_TOKENis not a substitute.auth status anthropicreports "logged in", but the gateway 401s at inference against api.anthropic.com and silently falls back. Only the credential minted through the OAuth login (stored in.anthropic_oauth.json) gets the bearer/beta handling the Messages API expects. Fixing the login endpoint is the real unblock, not the env var.Minor: repeated exchange attempts 429 on both hosts for a few minutes, which can read as a second failure mode. It isn't.
teknium1 commentedon Jun 24, 2026
Fixed on
mainvia #51723. The Anthropic OAuth login token exchange now targetsplatform.claude.comfirst (withconsole.anthropic.comas fallback), mirroring the refresh path — both the CLI login and the dashboard OAuth flow. Credit to @yusekiotacode (salvage of #48706).#51723