OAuth2PasswordBearer
OAuth2 flow for authentication using a bearer token obtained with a password. An instance of it would be used as a dependency.
Constructor
Signature
def OAuth2PasswordBearer(
tokenUrl: str = null,
scheme_name: str | None = None,
scopes: dict[str, str]| None = None,
description: str | None = None,
auto_error: bool = True,
refreshUrl: str | None = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| tokenUrl | str = null | The URL to obtain the OAuth2 token. This would be the path operation that has OAuth2PasswordRequestForm as a dependency. Read more about it in the FastAPI docs for Simple OAuth2 with Password and Bearer. |
| 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). |
| refreshUrl | `str | None` = None |