Fix OAuth2 resource parameter compliance with RFC 8707 #261815
Merged
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.
Summary
This PR fixes VS Code's OAuth2 flow to comply with RFC 8707 by including the resource parameter in token exchange requests.
Problem
The current implementation includes the resource indicator in the authorization request but omits it from both the authorization code and refresh token exchange requests. This violates RFC 8707 and can cause token validation failures on protected resources that require the resource parameter to be consistently present throughout the OAuth2 flow.
Solution
Added the resource parameter to both token exchange methods in the
DynamicAuthProviderclass:exchangeCodeForToken()- now includes resource parameter when exchanging authorization code for tokensexchangeRefreshTokenForToken()- now includes resource parameter when refreshing tokensThe fix ensures that when
_resourceMetadata?.resourceis available, it is consistently included in all OAuth2 requests throughout the authentication flow.Test Plan
Fixes #261364