HTTPBasic
HTTP Basic authentication.
Attributes
| Attribute | Type | Description |
|---|---|---|
| model | HTTPBaseModel | An internal OpenAPI model representing the security scheme with the scheme type set to basic. |
| scheme_name | `str | None` |
| realm | `str | None` |
| auto_error | bool = True | Determines if the dependency should automatically raise an error or return None when authentication is missing or invalid. |
Constructor
Signature
def HTTPBasic(
scheme_name: str | None = None,
realm: str | None = None,
description: str | None = None,
auto_error: bool = True
)
Parameters
| Name | Type | Description |
|---|---|---|
| scheme_name | `str | None` = None |
| realm | `str | None` = None |
| description | `str | None` = None |
| auto_error | bool = True | If True, missing credentials trigger an automatic error; if False, the dependency result is None. |
Signature
def HTTPBasic(
scheme_name: str | None = None,
realm: str | None = None,
description: str | None = None,
auto_error: bool = True
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| scheme_name | `str | None` = None |
| realm | `str | None` = None |
| description | `str | None` = None |
| auto_error | bool = True | Determines if the dependency should raise an error or return None when authentication is missing or invalid. |
Methods
make_authenticate_headers()
@classmethod
def make_authenticate_headers() - > dict[str, str]
Constructs the WWW-Authenticate header for the response, optionally including the defined realm.
Returns
| Type | Description |
|---|---|
dict[str, str] | A dictionary containing the WWW-Authenticate header key and its Basic authentication value. |