Skip to content

fix(auth): add platform.claude.com fallback to Anthropic OAuth token exchange - #48957

Closed
artemprudenkous90-sv wants to merge 1 commit into
NousResearch:mainfrom
artemprudenkous90-sv:fix/anthropic-oauth-token-exchange-fallback
Closed

fix(auth): add platform.claude.com fallback to Anthropic OAuth token exchange#48957
artemprudenkous90-sv wants to merge 1 commit into
NousResearch:mainfrom
artemprudenkous90-sv:fix/anthropic-oauth-token-exchange-fallback

Conversation

@artemprudenkous90-sv

Copy link
Copy Markdown

Problem

hermes auth add anthropic fails with:

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

The initial authorization code exchange in run_hermes_oauth_login_pure() only tries console.anthropic.com/v1/oauth/token, which returns 404.

Root cause

refresh_anthropic_oauth_pure() already has a two-endpoint fallback:

token_endpoints = [
    "https://platform.claude.com/v1/oauth/token",
    "https://console.anthropic.com/v1/oauth/token",
]

But the initial code exchange in run_hermes_oauth_login_pure() used only _OAUTH_TOKEN_URL (console.anthropic.com), missing the same fallback.

Fix

Apply the same fallback order to the initial token exchange — try platform.claude.com first, then console.anthropic.com.

Testing

Verified manually: hermes auth add anthropic now completes successfully with a Claude Max subscription.

…exchange

The initial authorization code exchange in run_hermes_oauth_login_pure()
was only trying console.anthropic.com/v1/oauth/token, which returns 404.

The refresh function (refresh_anthropic_oauth_pure) already had a fallback
to platform.claude.com/v1/oauth/token, but the same pattern was missing
from the initial code exchange.

Apply the same fallback order — try platform.claude.com first, then
console.anthropic.com — so that Claude Pro/Max OAuth via
`hermes auth add anthropic` works reliably.

Fixes: hermes auth add anthropic fails with 'Token exchange failed: HTTP Error 404'
@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 provider/anthropic Anthropic native Messages API area/auth Authentication, OAuth, credential pools P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Jun 19, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #48706 — same fix: both make the initial authorization-code exchange in run_hermes_oauth_login_pure() iterate [platform.claude.com, console.anthropic.com] with a fallback loop (mirroring the refresh path), addressing the console.anthropic.com 404. #48706 is the earlier open PR (it additionally extracts an _OAUTH_TOKEN_URLS constant and updates hermes_cli/web_server.py). Tracking issue: #45250 (see also #47692).

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

  • Well-scoped fix adding platform.claude.com fallback to Anthropic OAuth token exchange
  • Clean iteration over token endpoints: tries primary first, falls back to platform.claude.com if it fails
  • Proper error handling: stores last_error and raises it with a clear message if all endpoints fail
  • Preserves all original request headers and payload structure
  • No silent swallowing of errors; the outer try/except still catches and reports the final failure
  • Minimal diff, no unnecessary refactoring

Reviewed by Hermes Agent

@alaamohanad169-ship-it

Copy link
Copy Markdown
Contributor

Note: This is NOT a duplicate of the prior closed PRs (#48706, #48706, #45250, #47692). The earlier PRs were closed because they were stale (far behind upstream main). This version has been cherry-picked onto the latest origin/main with a clean diff containing only the fix changes. No conflicts. CI green. Ready for review.

@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 P2 Medium — degraded but workaround exists provider/anthropic Anthropic native Messages API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants