@@ -431,67 +431,7 @@ def _select_scopes(self, init_response: httpx.Response) -> None:
431431 # Priority 3: Omit scope parameter
432432 self .context .client_metadata .scope = None
433433
434- #<<<<<<< main
435434 # Discovery and registration helpers provided by BaseOAuthProvider
436- #=======
437- def _get_discovery_urls (self ) -> list [str ]:
438- """Generate ordered list of (url, type) tuples for discovery attempts."""
439- urls : list [str ] = []
440- auth_server_url = self .context .auth_server_url or self .context .server_url
441- parsed = urlparse (auth_server_url )
442- base_url = f"{ parsed .scheme } ://{ parsed .netloc } "
443-
444- # RFC 8414: Path-aware OAuth discovery
445- if parsed .path and parsed .path != "/" :
446- oauth_path = f"/.well-known/oauth-authorization-server{ parsed .path .rstrip ('/' )} "
447- urls .append (urljoin (base_url , oauth_path ))
448-
449- # OAuth root fallback
450- urls .append (urljoin (base_url , "/.well-known/oauth-authorization-server" ))
451-
452- # RFC 8414 section 5: Path-aware OIDC discovery
453- # See https://www.rfc-editor.org/rfc/rfc8414.html#section-5
454- if parsed .path and parsed .path != "/" :
455- oidc_path = f"/.well-known/openid-configuration{ parsed .path .rstrip ('/' )} "
456- urls .append (urljoin (base_url , oidc_path ))
457-
458- # OIDC 1.0 fallback (appends to full URL per OIDC spec)
459- oidc_fallback = f"{ auth_server_url .rstrip ('/' )} /.well-known/openid-configuration"
460- urls .append (oidc_fallback )
461-
462- return urls
463-
464- async def _register_client (self ) -> httpx .Request | None :
465- """Build registration request or skip if already registered."""
466- if self .context .client_info :
467- return None
468-
469- if self .context .oauth_metadata and self .context .oauth_metadata .registration_endpoint :
470- registration_url = str (self .context .oauth_metadata .registration_endpoint )
471- else :
472- auth_base_url = self .context .get_authorization_base_url (self .context .server_url )
473- registration_url = urljoin (auth_base_url , "/register" )
474-
475- registration_data = self .context .client_metadata .model_dump (by_alias = True , mode = "json" , exclude_none = True )
476-
477- return httpx .Request (
478- "POST" , registration_url , json = registration_data , headers = {"Content-Type" : "application/json" }
479- )
480-
481- async def _handle_registration_response (self , response : httpx .Response ) -> None :
482- """Handle registration response."""
483- if response .status_code not in (200 , 201 ):
484- await response .aread ()
485- raise OAuthRegistrationError (f"Registration failed: { response .status_code } { response .text } " )
486-
487- try :
488- content = await response .aread ()
489- client_info = OAuthClientInformationFull .model_validate_json (content )
490- self .context .client_info = client_info
491- await self .context .storage .set_client_info (client_info )
492- except ValidationError as e : # pragma: no cover
493- raise OAuthRegistrationError (f"Invalid registration response: { e } " )
494- #>>>>>>> main
495435
496436 async def _perform_authorization (self ) -> httpx .Request :
497437 """Perform the authorization flow."""
@@ -644,13 +584,8 @@ async def _refresh_token(self) -> httpx.Request:
644584 if self .context .should_include_resource_param (self .context .protocol_version ):
645585 refresh_data ["resource" ] = self .context .get_resource_url () # RFC 8707
646586
647- #<<<<<<< main
648587 headers = {"Content-Type" : "application/x-www-form-urlencoded" }
649588 self ._apply_client_auth (refresh_data , headers , self .context .client_info )
650- #=======
651- if self .context .client_info .client_secret : # pragma: no branch
652- refresh_data ["client_secret" ] = self .context .client_info .client_secret
653- #>>>>>>> main
654589
655590 return httpx .Request ("POST" , token_url , data = refresh_data , headers = headers )
656591
@@ -734,13 +669,10 @@ async def async_auth_flow(self, request: httpx.Request) -> AsyncGenerator[httpx.
734669 self ._select_scopes (response )
735670
736671 # Step 3: Discover OAuth metadata (with fallback for legacy servers)
737- #<<<<<<< main
738- discovery_urls = self ._get_discovery_urls (self .context .auth_server_url or self .context .server_url )
672+ discovery_urls = self ._get_discovery_urls (
673+ self .context .auth_server_url or self .context .server_url
674+ )
739675 for url in discovery_urls :
740- #=======
741- discovery_urls = self ._get_discovery_urls ()
742- for url in discovery_urls : # pragma: no branch
743- #>>>>>>> main
744676 oauth_metadata_request = self ._create_oauth_metadata_request (url )
745677 oauth_metadata_response = yield oauth_metadata_request
746678
0 commit comments