OAuth2PasswordRequestForm
This is a dependency class to collect the username and password as form data for an OAuth2 password flow. The OAuth2 specification dictates that for a password flow the data should be collected using form data (instead of JSON) and that it should have the specific fields username and password. All the initialization parameters are extracted from the request.
Attributes
| Attribute | Type | Description |
|---|---|---|
| grant_type | `str | None` = None |
| username | str | username string. The OAuth2 spec requires the exact field name username. |
| password | str | password string. The OAuth2 spec requires the exact field name password. |
| scopes | list[str] = '' | A single string with actually several scopes separated by spaces. Each scope is also a string. |
| client_id | `str | None` = None |
| client_secret | `str | None` = None |
Constructor
Signature
def OAuth2PasswordRequestForm(
grant_type: str | None = None,
username: str = null,
password: str = null,
scope: str = "",
client_id: str | None = None,
client_secret: str | None = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| grant_type | `str | None` = None |
| username | str = null | username string. The OAuth2 spec requires the exact field name username. Read more about it in the FastAPI docs for Simple OAuth2 with Password and Bearer. |
| password | str = null | password string. The OAuth2 spec requires the exact field name password. Read more about it in the FastAPI docs for Simple OAuth2 with Password and Bearer. |
| scope | str = "" | A single string with actually several scopes separated by spaces. Each scope is also a string. For example, a single string with: ```python "items:read items:write users:read profile openid" ```` would represent the scopes: * items:read * items:write * users:read * profile * openid Read more about it in the FastAPI docs for Simple OAuth2 with Password and Bearer. |
| client_id | `str | None` = None |
| client_secret | `str | None` = None |
Signature
def OAuth2PasswordRequestForm(
grant_type: str | None = None,
username: str,
password: str,
scope: str = "",
client_id: str | None = None,
client_secret: str | None = None
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| grant_type | `str | None` = None |
| username | str | username string. The OAuth2 spec requires the exact field name username. |
| password | str | password string. The OAuth2 spec requires the exact field name password. |
| scope | str = "" | A single string with actually several scopes separated by spaces. Each scope is also a string. For example, a single string with: python "items:read items:write users:read profile openid" would represent the scopes: * items:read * items:write * users:read * profile * openid |
| client_id | `str | None` = None |
| client_secret | `str | None` = None |