OAuth2AuthorizationCodeBearer
OAuth2 flow for authentication using a bearer token obtained with an OAuth2 code flow. An instance of it would be used as a dependency.
Constructor
Signature
def OAuth2AuthorizationCodeBearer(
authorizationUrl: str,
tokenUrl: str,
refreshUrl: str | None = None,
scheme_name: str | None = None,
scopes: dict[str, str]| None = None,
description: str | None = None,
auto_error: bool = True
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| authorizationUrl | str | The URL to obtain the OAuth2 token. |
| tokenUrl | str | The URL to obtain the OAuth2 token. |
| refreshUrl | `str | None` = None |
| scheme_name | `str | None` = None |
| scopes | `dict[str, str] | None` = None |
| description | `str | None` = None |
| auto_error | bool = True | By default, if no HTTP Authorization header is provided, required for OAuth2 authentication, it will automatically cancel the request and send the client an error. If auto_error is set to False, when the HTTP Authorization header is not available, instead of erroring out, the dependency result will be None. This is useful when you want to have optional authentication. It is also useful when you want to have authentication that can be provided in one of multiple optional ways (for example, with OAuth2 or in a cookie). |