Skip to content

fix(auth): migrate Anthropic OAuth endpoints to platform.claude.com#2741

Closed
kshitijk4poor wants to merge 2 commits into
NousResearch:mainfrom
kshitijk4poor:fix/anthropic-oauth-platform-migration
Closed

fix(auth): migrate Anthropic OAuth endpoints to platform.claude.com#2741
kshitijk4poor wants to merge 2 commits into
NousResearch:mainfrom
kshitijk4poor:fix/anthropic-oauth-platform-migration

Conversation

@kshitijk4poor

@kshitijk4poor kshitijk4poor commented Mar 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Anthropic migrated their OAuth infrastructure from console.anthropic.com / claude.ai to platform.claude.com. Claude Code v2.1.81 already uses the new endpoints, but Hermes was still pointing at the old ones — causing 401 "Invalid bearer token" errors on every OAuth-authenticated API call.

How this was discovered: Extracted API URLs from the Claude Code v2.1.81 binary (strings on the Mach-O executable) and compared them against Hermes's hardcoded endpoints. All three OAuth URLs had changed:

Endpoint Before (broken) After (fixed)
Authorize claude.ai/oauth/authorize platform.claude.com/oauth/authorize
Token exchange console.anthropic.com/v1/oauth/token platform.claude.com/v1/oauth/token
Redirect URI console.anthropic.com/oauth/code/callback platform.claude.com/oauth/code/callback

Additional fixes in the same file

  • Added missing OAuth scopes to match Claude Code: user:file_upload, user:mcp_servers, user:sessions
  • Deduplicated CLIENT_ID in _refresh_oauth_token() — was hardcoding the UUID instead of using the shared _OAUTH_CLIENT_ID constant
  • Aligned _refresh_oauth_token() Content-Type from application/x-www-form-urlencoded to application/json, matching every other token exchange call in the file

After merging

Users with existing Hermes OAuth credentials will need to re-authenticate since tokens from the old endpoint are no longer valid:

python -m hermes_cli.main auth login --provider anthropic

Test plan

  • pytest tests/test_anthropic_adapter.py tests/test_anthropic_oauth_flow.py — 79 passed

Anthropic migrated their OAuth infrastructure from console.anthropic.com
and claude.ai to platform.claude.com. Claude Code v2.1.81 already uses
the new endpoints, but Hermes was still pointing to the old ones —
causing "Invalid bearer token" (401) errors on every OAuth-authenticated
API call.

Changes:
- Token URL: console.anthropic.com → platform.claude.com
- Redirect URI: console.anthropic.com → platform.claude.com
- Authorize URL: claude.ai → platform.claude.com
- Add missing scopes: user:file_upload, user:mcp_servers, user:sessions
- Deduplicate CLIENT_ID constant in _refresh_oauth_token()
- Align _refresh_oauth_token() to use JSON body (matching all other
  token exchange calls) instead of form-urlencoded
Deduplicate the identical OAuth token refresh HTTP call that was
copy-pasted between _refresh_oauth_token() and refresh_hermes_oauth_token().
Both callers now delegate the HTTP exchange to _exchange_refresh_token()
and only handle credential persistence themselves.
teknium1 added a commit that referenced this pull request Mar 26, 2026
…llback

Anthropic migrated their OAuth infrastructure from console.anthropic.com
to platform.claude.com (Claude Code v2.1.81+). Update _refresh_oauth_token()
to try the new endpoint first, falling back to the old one for tokens
issued before the migration.

Also switches Content-Type from application/x-www-form-urlencoded to
application/json to match current Claude Code behavior.

Salvaged from PR #2741 by kshitijk4poor.
teknium1 added a commit that referenced this pull request Mar 26, 2026
…llback (#3246)

Anthropic migrated their OAuth infrastructure from console.anthropic.com
to platform.claude.com (Claude Code v2.1.81+). Update _refresh_oauth_token()
to try the new endpoint first, falling back to the old one for tokens
issued before the migration.

Also switches Content-Type from application/x-www-form-urlencoded to
application/json to match current Claude Code behavior.

Salvaged from PR #2741 by kshitijk4poor.
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #3246. Your OAuth endpoint migration fix was salvaged onto current main — the PKCE flow your PR also modified was removed in 910ec7e, so only the surviving _refresh_oauth_token() update was cherry-picked. Added fallback to the old endpoint for tokens issued before the migration. Thanks for catching this!

@teknium1 teknium1 closed this Mar 26, 2026
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…llback (NousResearch#3246)

Anthropic migrated their OAuth infrastructure from console.anthropic.com
to platform.claude.com (Claude Code v2.1.81+). Update _refresh_oauth_token()
to try the new endpoint first, falling back to the old one for tokens
issued before the migration.

Also switches Content-Type from application/x-www-form-urlencoded to
application/json to match current Claude Code behavior.

Salvaged from PR NousResearch#2741 by kshitijk4poor.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…llback (NousResearch#3246)

Anthropic migrated their OAuth infrastructure from console.anthropic.com
to platform.claude.com (Claude Code v2.1.81+). Update _refresh_oauth_token()
to try the new endpoint first, falling back to the old one for tokens
issued before the migration.

Also switches Content-Type from application/x-www-form-urlencoded to
application/json to match current Claude Code behavior.

Salvaged from PR NousResearch#2741 by kshitijk4poor.
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
…llback (NousResearch#3246)

Anthropic migrated their OAuth infrastructure from console.anthropic.com
to platform.claude.com (Claude Code v2.1.81+). Update _refresh_oauth_token()
to try the new endpoint first, falling back to the old one for tokens
issued before the migration.

Also switches Content-Type from application/x-www-form-urlencoded to
application/json to match current Claude Code behavior.

Salvaged from PR NousResearch#2741 by kshitijk4poor.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…llback (NousResearch#3246)

Anthropic migrated their OAuth infrastructure from console.anthropic.com
to platform.claude.com (Claude Code v2.1.81+). Update _refresh_oauth_token()
to try the new endpoint first, falling back to the old one for tokens
issued before the migration.

Also switches Content-Type from application/x-www-form-urlencoded to
application/json to match current Claude Code behavior.

Salvaged from PR NousResearch#2741 by kshitijk4poor.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
…llback (NousResearch#3246)

Anthropic migrated their OAuth infrastructure from console.anthropic.com
to platform.claude.com (Claude Code v2.1.81+). Update _refresh_oauth_token()
to try the new endpoint first, falling back to the old one for tokens
issued before the migration.

Also switches Content-Type from application/x-www-form-urlencoded to
application/json to match current Claude Code behavior.

Salvaged from PR NousResearch#2741 by kshitijk4poor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants