Skip to content

Conversation

chipgpt
Copy link

@chipgpt chipgpt commented Sep 29, 2025

Updates the OAuth authorization flow to prefer to use the token_endpoint_auth_method result from the Dynamic Client Registration endpoint, if provided.

Fixes #951

Motivation and Context

When using dynamic client registration, the registration endpoint may return the token_endpoint_auth_method value to be used when exchanging tokens for access tokens. The current oauth implementation ignores this field and only uses the methods from the oauth authorization server metadata.

How Has This Been Tested?

This has not been tested in a real application.

Breaking Changes

No breaking changes.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

This is my first stab at a PR for this project. Go easy on me xD.

@chipgpt chipgpt requested review from a team, pcarleton and ihrpr September 29, 2025 22:05
(mockProvider.clientInformation as jest.Mock).mockResolvedValue({
client_id: "test-client",
client_secret: "test-secret",
redirect_uris: ["http://localhost:3000/callback"],
Copy link
Author

Choose a reason for hiding this comment

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

Adding the redirect_uris to all the mock objects to match the new type OAuthClientInformationFull

Comment on lines +168 to +176
// Prefer the method returned by the server during client registration if valid and supported
if (
clientInformation.token_endpoint_auth_method &&
isClientAuthMethod(clientInformation.token_endpoint_auth_method) &&
supportedMethods.includes(clientInformation.token_endpoint_auth_method)
) {
return clientInformation.token_endpoint_auth_method;
}

Copy link
Author

@chipgpt chipgpt Sep 29, 2025

Choose a reason for hiding this comment

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

Should this throw an error if an invalid or unsupported token_endpoint_auth_method is returned? This implementation would simply skip it and fall through to the rest of the logic if it is invalid or unsupported.

On the other hand, should it even care if it's valid or supported in this context? or should it just use the token_endpoint_auth_method value without validating it at all?

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.

Prefer token endpoint auth method obtained during OAuth client registration
2 participants