Skip to content

feat(auth): add token_endpoint_auth_method to OAuthClientConfig#1

Closed
anara123 wants to merge 8 commits intomainfrom
feat/token-endpoint-auth-method
Closed

feat(auth): add token_endpoint_auth_method to OAuthClientConfig#1
anara123 wants to merge 8 commits intomainfrom
feat/token-endpoint-auth-method

Conversation

@anara123
Copy link

@anara123 anara123 commented Feb 9, 2026

Summary

  • Add token_endpoint_auth_method: Option<String> to OAuthClientConfig so callers can choose between client_secret_post (POST body) and client_secret_basic (HTTP Basic Auth, the default)
  • Fixes TokenExchangeFailed errors with OAuth providers like HubSpot that require credentials in the POST body
  • Unknown auth method values are silently ignored, preserving the oauth2 crate's default (BasicAuth)

Test plan

  • Added 4 unit tests covering client_secret_post, client_secret_basic, None, and unknown method values
  • cargo clippy -p rmcp --features auth -- -D warnings passes clean
  • All existing tests continue to pass

🤖 Generated with Claude Code

Anar Azadaliyev and others added 8 commits February 9, 2026 10:03
Some OAuth providers (e.g. HubSpot) require client credentials to be
sent as POST body parameters (client_secret_post) instead of via HTTP
Basic Auth header. The oauth2 crate defaults to BasicAuth, and rmcp
had no way to override this, causing TokenExchangeFailed errors.

Add an optional `token_endpoint_auth_method` field to OAuthClientConfig
that accepts "client_secret_post" (RequestBody) and "client_secret_basic"
(BasicAuth). Unknown values are silently ignored, preserving the default.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move auth method selection from per-client config to server's
AuthorizationMetadata, which is the correct OAuth 2.0 approach.
Servers like HubSpot advertise token_endpoint_auth_methods_supported
in their metadata; reading it from there avoids manual configuration
and prevents TokenExchangeFailed errors with non-BasicAuth providers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ional_fields

Move token_endpoint_auth_methods_supported out of AuthorizationMetadata
as an explicit field and read it from the serde(flatten) additional_fields
HashMap instead. This avoids serializing `null` when the field is absent,
which broke Zod validation in downstream consumers like MCP Inspector.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… test assertions

When token_endpoint_auth_methods_supported contains both client_secret_post
and client_secret_basic, default to basic auth per RFC 6749 §2.3.1.
Update configure_client tests to assert actual AuthType instead of is_some().

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@anara123
Copy link
Author

This pr was merged to the original repo here: modelcontextprotocol#648

@anara123 anara123 closed this Feb 15, 2026
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.

1 participant