Security
Declare a FastAPI Security dependency. The only difference with a regular dependency is that it can declare OAuth2 scopes that will be integrated with OpenAPI and the automatic UI docs (by default at /docs). It takes a single "dependable" callable (like a function).
def Security(
dependency: Callable[..., Any] | None = None,
scopes: Sequence[str] | None = None,
use_cache: bool = True
) - > Any
Declare a FastAPI Security dependency. The only difference with a regular dependency is that it can declare OAuth2 scopes that will be integrated with OpenAPI and the automatic UI docs (by default at /docs). It takes a single "dependable" callable (like a function). Don't call it directly, FastAPI will call it for you.
Parameters
| Name | Type | Description |
|---|---|---|
| dependency | `Callable[..., Any] | None` = None |
| scopes | `Sequence[str] | None` = None |
| use_cache | bool = True | Controls whether the dependency's value is re-used for the rest of the request after its first call. Set to False to disable caching and ensure the dependency is called again if declared more than once in the same request. |
Returns
| Type | Description |
|---|---|
Any |