def get_oauth_router(self, oauth_client: BaseOAuth2, state_secret: str, redirect_url: str = None) -> EventHandlersRouter: """ Return an OAuth router for a given OAuth client. :param oauth_client: The HTTPX OAuth client instance. :param state_secret: Secret used to encode the state JWT. :param redirect_url: Optional arbitrary redirect URL for the OAuth2 flow. If not given, the URL to the callback endpoint will be generated. """ oauth_router = get_oauth_router( oauth_client, self.db, self._user_db_model, self.authenticator, state_secret, redirect_url, ) for event_type in self._event_handlers: for handler in self._event_handlers[event_type]: oauth_router.add_event_handler(event_type, handler) self.oauth_routers.append(oauth_router) return oauth_router
def get_oauth_router( self, oauth_client: BaseOAuth2, state_secret: str, redirect_url: str = None, after_register: Optional[Callable[[models.UD, Request], None]] = None, ) -> APIRouter: """ Return an OAuth router for a given OAuth client. :param oauth_client: The HTTPX OAuth client instance. :param state_secret: Secret used to encode the state JWT. :param redirect_url: Optional arbitrary redirect URL for the OAuth2 flow. If not given, the URL to the callback endpoint will be generated. :param after_register: Optional function called after a successful registration. """ return get_oauth_router( oauth_client, self.db, self._user_db_model, self.authenticator, state_secret, redirect_url, after_register, )
def get_oauth_router( self, oauth_client: BaseOAuth2, backend: AuthenticationBackend, state_secret: SecretType, redirect_url: str = None, ) -> APIRouter: """ Return an OAuth router for a given OAuth client and authentication backend. :param oauth_client: The HTTPX OAuth client instance. :param backend: The authentication backend instance. :param state_secret: Secret used to encode the state JWT. :param redirect_url: Optional arbitrary redirect URL for the OAuth2 flow. If not given, the URL to the callback endpoint will be generated. """ return get_oauth_router( oauth_client, backend, self.get_user_manager, state_secret, redirect_url, )