APIKeyQuery
API key authentication using a query parameter. This defines the name of the query parameter 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 query parameter automatically and provides it as the dependency result. But it doesn't define how to send that API key to the client.
Attributes
| Attribute | Type | Description |
|---|---|---|
| name | str | Query parameter name. |
| scheme_name | `str | None` = None |
| description | `str | None` = None |
| auto_error | bool = True | If set to False, the dependency result will be None instead of automatically canceling the request when the query parameter is not provided. |
Constructor
Signature
def APIKeyQuery(
name: str,
scheme_name: str | None = None,
description: str | None = None,
auto_error: bool = True
)
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | Query parameter name. |
| scheme_name | `str | None` = None |
| description | `str | None` = None |
| auto_error | bool = True | If True, missing credentials trigger an automatic error; if False, the dependency returns None. |
Signature
def APIKeyQuery(
name: str,
scheme_name: str | None = None,
description: str | None = None,
auto_error: bool = True
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| name | str | The name of the query parameter that should contain the API key. |
| scheme_name | `str | None` = None |
| description | `str | None` = None |
| auto_error | bool = True | Determines if the request should be automatically rejected with an error if the API key is missing; set to False for optional authentication. |