APIKeyCookie
API key authentication using a cookie.
This defines the name of the cookie that should be provided in the request with the API key and integrates that into the OpenAPI documentation. It extracts the key value sent in the cookie automatically and provides it as the dependency result. But it doesn't define how to set that cookie.
Attributes
| Attribute | Type | Description |
|---|---|---|
| name | str | Cookie name. |
| scheme_name | `str | None` = None |
| description | `str | None` = None |
| auto_error | bool = True | By default, if the cookie is not provided, APIKeyCookie will automatically cancel the request and send the client an error; if set to False, the dependency result will be None instead. |
Constructor
Signature
def APIKeyCookie(
name: str,
scheme_name: str | None = None,
description: str | None = None,
auto_error: bool = True
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | Cookie name. |
| scheme_name | `str | None` = None |
| description | `str | None` = None |
| auto_error | bool = True | If True, missing cookies result in an error; if False, the dependency result is None. |
Signature
def APIKeyCookie(
name: str,
scheme_name: str | null = None,
description: str | null = None,
auto_error: bool = True
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | The name of the cookie that should be provided in the request containing the API key. |
| scheme_name | `str | null` = None |
| description | `str | null` = None |
| auto_error | bool = True | Determines if the request should be automatically rejected with an error if the cookie is missing; set to False for optional authentication. |