fix(auth): add platform.claude.com fallback to Anthropic OAuth token exchange - #48957
Conversation
…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'
|
Duplicate of #48706 — same fix: both make the initial authorization-code exchange in |
tonydwb
left a comment
There was a problem hiding this comment.
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
|
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. |
|
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. |
Problem
hermes auth add anthropicfails with:The initial authorization code exchange in
run_hermes_oauth_login_pure()only triesconsole.anthropic.com/v1/oauth/token, which returns 404.Root cause
refresh_anthropic_oauth_pure()already has a two-endpoint fallback: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.comfirst, thenconsole.anthropic.com.Testing
Verified manually:
hermes auth add anthropicnow completes successfully with a Claude Max subscription.