feat: include granted scopes in OAuth refresh token request#731
Merged
feat: include granted scopes in OAuth refresh token request#731
Conversation
alexhancock
approved these changes
Mar 9, 2026
| ); | ||
| } | ||
|
|
||
| async fn start_token_server() -> (String, Arc<std::sync::Mutex<Option<String>>>) { |
Contributor
There was a problem hiding this comment.
we should #[cfg(test)] this yeah?
Member
Author
There was a problem hiding this comment.
This is a private helper inside the #[cfg(test)] mod tests block, so it should be already gated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #624
Motivation and Context
RFC 6749 allows sending a
scopeparameter with refresh token requests, and some providers, especially Azure AD v2, actually require it. If you don't include it, the refresh might succeed quietly, but it will return a token without any scopes, or the server might reject the request altogether.This fix keeps the full
StoredCredentials, allowing us to add the previously granted scopes to the outgoing refresh request using.add_scope(). This follows the same pattern we already use in the authorization code and client credentials flows. Ifgranted_scopesis empty, we won't send ascopeparameter, which maintains the current behavior for providers that don't need it.rust-sdk/crates/rmcp/src/transport/auth.rs
Line 913 in 5c5a2e7
rust-sdk/crates/rmcp/src/transport/auth.rs
Line 1766 in 5c5a2e7
How Has This Been Tested?
Added unit tests
Breaking Changes
None. Providers that don't accept a
scopeparameter on refresh requests will continue to work as before, since the parameter is only added when scopes were previously granted.Types of changes
Checklist