Preserve scopes in token refresh request#4428
Merged
amirejaz merged 1 commit intostacklok:mainfrom Mar 30, 2026
Merged
Conversation
RFC 6749 section 6 says servers MUST preserve scopes when the scope parameter is omitted from a refresh request, but not all servers comply. Explicitly including scope during refresh is always spec-safe and protects users from silent scope loss on non-compliant servers. Fixes stacklok#4427 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Greg Katz <gkatz@indeed.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4428 +/- ##
==========================================
- Coverage 69.50% 69.48% -0.02%
==========================================
Files 486 486
Lines 50017 50019 +2
==========================================
- Hits 34766 34758 -8
- Misses 12570 12577 +7
- Partials 2681 2684 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
amirejaz
approved these changes
Mar 30, 2026
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.
Summary
scopeparameter inrefreshWithResource()whenconfig.Scopesis non-empty, matching the existing defensive approach for the RFC 8707resourceparameterFixes #4427
Type of change
Test plan
task test)task lint-fix)Does this introduce a user-facing change?
Users connecting to OAuth servers that don't preserve scopes during token refresh will no longer silently lose scopes. Previously, scoped tool calls would fail after token expiry until manual re-auth.
Special notes for reviewers
resourceTokenSourcealready exists because Go's standardoauth2library doesn't support adding custom parameters during refresh. This change extends that philosophy toscope: while RFC 6749 section 6 says servers MUST preserve scopes when omitted, being explicit is always spec-safe and protects against non-compliant servers.Generated with Claude Code