Skip to content

fix(anthropic): use platform.claude.com for OAuth token exchange - #49356

Closed
ThinkCode wants to merge 1 commit into
NousResearch:mainfrom
ThinkCode:fix/anthropic-oauth-token-endpoint
Closed

fix(anthropic): use platform.claude.com for OAuth token exchange#49356
ThinkCode wants to merge 1 commit into
NousResearch:mainfrom
ThinkCode:fix/anthropic-oauth-token-endpoint

Conversation

@ThinkCode

Copy link
Copy Markdown

Summary

hermes auth add anthropic --type oauth fails at the token-exchange step with:

Token exchange failed: HTTP Error 404: Not Found
Anthropic OAuth login did not return credentials.

Root cause

run_hermes_oauth_login_pure() in agent/anthropic_adapter.py POSTs the authorization code to https://console.anthropic.com/v1/oauth/token (_OAUTH_TOKEN_URL). Anthropic has retired that endpoint — it now returns HTTP 404. The browser authorize step and PKCE/state validation all succeed; only the exchange fails.

Notably, the token refresh path (refresh_anthropic_oauth_pure) was already updated to try platform.claude.com first with the console host as fallback. The login exchange was missed.

Fix

Make the login token exchange try https://platform.claude.com/v1/oauth/token first, falling back to the legacy console host — mirroring the existing refresh logic. If all endpoints fail, the last error is surfaced as before.

Test plan

  • Reproduced the 404 on the old single-endpoint path
  • With the fix, hermes auth add anthropic --type oauth completes: Added anthropic OAuth credential, and hermes auth status anthropic reports logged in
  • Lint clean

The OAuth login token exchange POSTed the authorization code to
console.anthropic.com/v1/oauth/token, which Anthropic has retired
(now returns HTTP 404), so 'hermes auth add anthropic --type oauth'
failed with 'Token exchange failed: HTTP Error 404: Not Found'.

Try platform.claude.com first and fall back to the legacy console
host, mirroring the multi-endpoint logic already used by the token
refresh path (refresh_anthropic_oauth_pure).
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint area/auth Authentication, OAuth, credential pools provider/anthropic Anthropic native Messages API P1 High — major feature broken, no workaround duplicate This issue or pull request already exists labels Jun 20, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #48957 — both patch run_hermes_oauth_login_pure() in agent/anthropic_adapter.py with the identical mechanism: replace the single bare _OAUTH_TOKEN_URL POST with a token_endpoints = ["https://platform.claude.com/v1/oauth/token", _OAUTH_TOKEN_URL] list, loop with try/except, and raise the last error if all endpoints fail. #48957 (artemprudenkous90-sv) was opened earlier (2026-06-19) and is still open, so it's the canonical version.

Related bug reports: #47692, #45250. (Earlier same-fix attempts #47474, #47333, #46251, #45441, #46769 are all closed.)

@teknium1 teknium1 added sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jun 21, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Closing as a duplicate. This was fixed via #51723 (salvage of #48706 by @yusekiotacode, which fixed both the CLI login and dashboard OAuth paths). Thanks for the report and the fix — credited in the cluster.

#51723

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P1 High — major feature broken, no workaround provider/anthropic Anthropic native Messages API sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants