@@ -272,14 +272,13 @@ async def _handle_protected_resource_response(self, response: httpx.Response) ->
272272 else :
273273 raise OAuthFlowError (f"Protected Resource Metadata request failed: { response .status_code } " )
274274
275- def _configure_scope_selection (self , init_response : httpx .Response ) -> None :
275+ def _select_scopes (self , init_response : httpx .Response ) -> None :
276276 """Select scopes as outlined in the 'Scope Selection Strategy in the MCP spec."""
277277 # Per MCP spec, scope selection priority order:
278278 # 1. Use scope from WWW-Authenticate header (if provided)
279279 # 2. Use all scopes from PRM scopes_supported (if available)
280280 # 3. Omit scope parameter if neither is available
281281 #
282- # Step 1: Extract scope from WWW-Authenticate header
283282 www_authenticate_scope = self ._extract_scope_from_www_auth (init_response )
284283 if www_authenticate_scope is not None :
285284 # Priority 1: WWW-Authenticate header scope
@@ -555,7 +554,7 @@ async def async_auth_flow(self, request: httpx.Request) -> AsyncGenerator[httpx.
555554 await self ._handle_protected_resource_response (discovery_response )
556555
557556 # Step 2: Apply scope selection strategy
558- self ._configure_scope_selection (response )
557+ self ._select_scopes (response )
559558
560559 # Step 3: Discover OAuth metadata (with fallback for legacy servers)
561560 discovery_urls = self ._get_discovery_urls ()
@@ -600,7 +599,7 @@ async def async_auth_flow(self, request: httpx.Request) -> AsyncGenerator[httpx.
600599 if error == "insufficient_scope" :
601600 try :
602601 # Step 2a: Update the required scopes
603- self ._configure_scope_selection (response )
602+ self ._select_scopes (response )
604603
605604 # Step 2b: Perform (re-)authorization
606605 auth_code , code_verifier = await self ._perform_authorization ()
0 commit comments