leaguemanager.lib.oauth¶
Module Contents¶
Classes¶
Error raised when an error occurs during the OAuth2 authorization callback. |
|
Dependency callable to handle the authorization callback. It reads the query parameters and returns the access token and the state. |
|
HTTPX OAuth2 Plugin configuration plugin. |
Data¶
API¶
- leaguemanager.lib.oauth.AccessTokenState: TypeAlias¶
None
- class leaguemanager.lib.oauth.OAuth2AuthorizeCallbackError(status_code: int, detail: Any = None, headers: dict[str, str] | None = None, response: httpx.Response | None = None, extra: dict[str, Any] | list[Any] | None = None)¶
Bases:
httpx_oauth.oauth2.OAuth2Error,litestar.exceptions.HTTPExceptionError raised when an error occurs during the OAuth2 authorization callback.
It inherits from HTTPException, so you can either keep the default Litestar error handling or implement something dedicated.
Note Due to the way the base
LitestarExceptionhandles thedetailargument, theOAuth2Erroris ordered first hereInitialization
- class leaguemanager.lib.oauth.OAuth2AuthorizeCallback(client: httpx_oauth.oauth2.BaseOAuth2, route_name: str | None = None, redirect_url: str | None = None)¶
Dependency callable to handle the authorization callback. It reads the query parameters and returns the access token and the state.
Example ```py from litestar import get from httpx_oauth.integrations.litestar import OAuth2AuthorizeCallback from httpx_oauth.oauth2 import OAuth2
client = OAuth2("CLIENT_ID", "CLIENT_SECRET", "AUTHORIZE_ENDPOINT", "ACCESS_TOKEN_ENDPOINT") oauth2_authorize_callback = OAuth2AuthorizeCallback(client, "oauth-callback") @get("/oauth-callback", name="oauth-callback", dependencies={"access_token_state": Provide(oauth2_authorize_callback)}) async def oauth_callback(access_token_state: AccessTokenState)) -> Response: token, state = access_token_state # Do something useful ```Initialization
Args: client: An [OAuth2][httpx_oauth.oauth2.BaseOAuth2] client. route_name: Name of the callback route, as defined in the
nameparameter of the route decorator. redirect_url: Full URL to the callback route.- client: httpx_oauth.oauth2.BaseOAuth2¶
None
- route_name: str | None¶
None
- redirect_url: str | None¶
None
- async __call__(request: litestar.Request, code: str | None = Parameter(query='code', required=False), code_verifier: str | None = Parameter(query='code_verifier', required=False), callback_state: str | None = Parameter(query='state', required=False), error: str | None = Parameter(query='error', required=False)) leaguemanager.lib.oauth.AccessTokenState¶
- class leaguemanager.lib.oauth.OAuth2ProviderPlugin¶
Bases:
litestar.plugins.InitPluginProtocolHTTPX OAuth2 Plugin configuration plugin.
- on_app_init(app_config: litestar.config.app.AppConfig) litestar.config.app.AppConfig¶
Configure application for use with SQLAlchemy.
Args: app_config: The :class:
AppConfig <.config.app.AppConfig>instance.