Fix Azure AD v2.0 compatibility by filtering unsupported 'resource' parameter #1864
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Problem
The Azure provider fails when MCP clients send the
resourceparameter (from RFC 8707 - OAuth 2.0 Resource Indicators) because Azure AD v2.0 endpoints don't support this parameter. Users get the error:Root Cause
The
OAuthProxybase class forwards all OAuth parameters includingresourceif present:While this is correct per OAuth 2.0 specs, Azure AD v2.0 specifically rejects this parameter. Azure AD v2.0 uses scopes (like
api://app-id/.default) to determine the resource/audience instead.Solution
Override the
authorizemethod inAzureProviderto filter out theresourceparameter before forwarding to Azure AD v2.0. This maintains compatibility with both:resourceparameter (following RFC 8707)Changes
authorizemethod override inAzureProviderclassAuthorizationParamsandOAuthClientInformationFullBackwards Compatibility
This change is fully backwards compatible. Existing Azure provider users will see no change in behavior unless they were experiencing the "resource parameter not supported" error.
AI generated code and PR description with Claude Opus 4.1
Contributors Checklist
Review Checklist