Skip to content

Respect configured OAuth scopes#1581

Open
pragnyanramtha wants to merge 1 commit into
modelcontextprotocol:mainfrom
pragnyanramtha:codex/restore-configured-oauth-scopes
Open

Respect configured OAuth scopes#1581
pragnyanramtha wants to merge 1 commit into
modelcontextprotocol:mainfrom
pragnyanramtha:codex/restore-configured-oauth-scopes

Conversation

@pragnyanramtha
Copy link
Copy Markdown

Summary

Fixes #1236.

ClientOAuthOptions.Scopes is documented as overriding scopes advertised by protected resource metadata, but ClientOAuthProvider only used configured scopes after scopes_supported was absent. This updates scope selection to keep challenge-provided WWW-Authenticate scopes authoritative, then prefer configured scopes, then fall back to protected resource metadata.

Validation

  • dotnet test tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj -f net10.0 --filter "FullyQualifiedName~AuthorizationFlow_Uses" --logger "console;verbosity=normal"
  • dotnet test tests/ModelContextProtocol.AspNetCore.Tests/ModelContextProtocol.AspNetCore.Tests.csproj -f net10.0 --no-build --filter "FullyQualifiedName~AuthorizationFlow_Uses" --logger "console;verbosity=minimal"
  • dotnet format whitespace ModelContextProtocol.slnx --verify-no-changes --include src/ModelContextProtocol.Core/Authentication/ClientOAuthProvider.cs tests/ModelContextProtocol.AspNetCore.Tests/OAuth/AuthTests.cs
  • git diff --check

Notes

Validation was focused on the OAuth scope-selection regression and adjacent scope-priority tests. Full multi-target test coverage was not run locally.

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 16, 2026 22:25
Copilot AI review requested due to automatic review settings May 16, 2026 22:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mikekistler mikekistler requested a review from halter73 May 17, 2026 13:27
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.

Specified ClientOAuthOptions.Scopes are ignored

2 participants