APIKeyHeader
API key authentication using a header.
This defines the name of the header 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 header automatically and provides it as the dependency result. But it doesn't define how to send that key to the client.
Constructor
Signature
def APIKeyHeader(
name: str = null,
scheme_name: str | None = None,
description: str | None = None,
auto_error: bool = True
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| name | str = null | Header name. |
| scheme_name | `str | None` = None |
| description | `str | None` = None |
| auto_error | bool = True | By default, if the header is not provided, APIKeyHeader will automatically cancel the request and send the client an error. If auto_error is set to False, when the 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, in a header or in an HTTP Bearer token). |