Title: OAuth client: keep refresh_token on non-rotating refresh; restore same-origin issuer binding by maxisbey · Pull Request #2946 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: OAuth client: keep refresh_token on non-rotating refresh; restore same-origin issuer binding by maxisbey · Pull Request #2946 · modelcontextprotocol/python-sdk
X Title: OAuth client: keep refresh_token on non-rotating refresh; restore same-origin issuer binding by maxisbey · Pull Request #2946 · modelcontextprotocol/python-sdk
Description: Two small follow-ups to #2936, from review on that PR. Motivation and Context Carry an omitted refresh_token forward on refresh. RFC 6749 §6 allows the AS to omit refresh_token from a refresh response when it does not rotate refresh tokens (common in practice). _handle_refresh_response was overwriting the stored token wholesale, dropping the still-valid prior refresh_token from both memory and storage, so the next expiry forced a full interactive re-authorization (or failed for headless clients). Carries it forward alongside the existing scope carry-forward. Restore the SEP-2352 issuer stamp for same-origin fallback registrations. #2936 stopped recording the issuer when dynamic client registration fell back to the resource origin's /register, to avoid binding a registration to a PRM-advertised AS we never reached. That gate also dropped the stamp in the legacy same-origin embedded-AS case — no PRM, root authorization-server metadata at the resource origin without registration_endpoint — where the fallback /register is on the discovered issuer's own host and the binding was genuinely established. Without the stamp, a later AS migration silently reuses the old credentials (credentials_match_issuer returns true for an unset issuer) instead of re-registering. The stamp is now also recorded when the fallback origin matches the discovered issuer's origin. How Has This Been Tested? test_handle_refresh_response_carries_prior_scope_and_refresh_token_when_omitted — refresh response with neither scope nor refresh_token keeps both prior values test_handle_refresh_response_adopts_rotated_refresh_token_when_returned — a returned refresh_token still replaces the prior one test_issuer_is_stamped_when_same_origin_fallback_register_is_on_the_discovered_issuer — PRM 404 → root ASM at the resource origin without registration_endpoint → fallback DCR → persisted record is bound to the discovered issuer The existing cross-origin parametrized test still asserts the issuer is left unset when the fallback hits a different host Breaking Changes None. Types of changes Bug fix (non-breaking change which fixes an issue) New feature (non-breaking change which adds functionality) Breaking change (fix or feature that would cause existing functionality to change) Documentation update Checklist I have read the MCP Documentation My code follows the repository's style guidelines New and existing tests pass locally I have added appropriate error handling I have added or updated documentation as needed AI Disclaimer
Open Graph Description: Two small follow-ups to #2936, from review on that PR. Motivation and Context Carry an omitted refresh_token forward on refresh. RFC 6749 §6 allows the AS to omit refresh_token from a refresh respo...
X Description: Two small follow-ups to #2936, from review on that PR. Motivation and Context Carry an omitted refresh_token forward on refresh. RFC 6749 §6 allows the AS to omit refresh_token from a refresh respo...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/2946
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:c8b5e17b-e39b-7051-4ac0-26ad65bb6fd8 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DB36:F3CF:15B0D57:1F0E7E8:6A5A29E7 |
| html-safe-nonce | b664e337bd461c2edc61adb1d34b3bada6b05c378fd01d72c8ce8f3bd050b420 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjM2OkYzQ0Y6MTVCMEQ1NzoxRjBFN0U4OjZBNUEyOUU3IiwidmlzaXRvcl9pZCI6IjkwNjgyNTE4MTI5MTEwMDAwNDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9ca381c8dac6964ae3a78b72610782fa34754536992f4ee6bb1add6c8c2b41b8 |
| hovercard-subject-tag | pull_request:3912439994 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/2946/files |
| twitter:image | https://avatars.githubusercontent.com/u/224885523?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/224885523?s=400&v=4 |
| og:image:alt | Two small follow-ups to #2936, from review on that PR. Motivation and Context Carry an omitted refresh_token forward on refresh. RFC 6749 §6 allows the AS to omit refresh_token from a refresh respo... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 19c67ad7579d2401ff06e88a32ef45460fbb40fab3191c7f7582d5e166f326fc |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a3dea2706161c733403beb02e41d5765d358d44e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width