mirror of https://github.com/tiangolo/fastapi.git
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
This commit is contained in:
parent
0f07f42e3f
commit
0fc3ff387d
|
|
@ -107,7 +107,7 @@ And you will also see how it gets automatically integrated into the interactive
|
|||
|
||||
## API Key in Header
|
||||
|
||||
An API key is a simple secret string that a client sends with every request.
|
||||
An API key is a simple secret string that a client sends with every request.
|
||||
It is often used for:
|
||||
|
||||
- machine-to-machine communication,
|
||||
|
|
@ -120,7 +120,7 @@ FastAPI provides tools for these in the `fastapi.security` module, including `AP
|
|||
|
||||
### Define an API key in a header
|
||||
|
||||
In this example, the client must send an API key in the HTTP header `X-API-Key`.
|
||||
In this example, the client must send an API key in the HTTP header `X-API-Key`.
|
||||
We’ll require the exact value `"supersecret"` to access a protected route.
|
||||
|
||||
```Python
|
||||
|
|
@ -135,5 +135,3 @@ API_KEY = "supersecret"
|
|||
API_KEY_NAME = "X-API-Key"
|
||||
|
||||
api_key_header = APIKeyHeader(name=API_KEY_NAME, auto_error=False)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ Y también verás cómo se integra automáticamente en el sistema de documentaci
|
|||
|
||||
## API Key en el Header
|
||||
|
||||
Una API key es una cadena secreta sencilla que un cliente envía con cada petición.
|
||||
Una API key es una cadena secreta sencilla que un cliente envía con cada petición.
|
||||
Suele utilizarse para:
|
||||
|
||||
- comunicación entre servicios,
|
||||
|
|
@ -120,7 +120,7 @@ FastAPI incluye utilidades para esto en el módulo `fastapi.security`, incluyend
|
|||
|
||||
### Definir la API key en un header
|
||||
|
||||
En este ejemplo, el cliente debe enviar una API key en el header HTTP `X-API-Key`.
|
||||
En este ejemplo, el cliente debe enviar una API key en el header HTTP `X-API-Key`.
|
||||
Requeriremos que el valor sea exactamente `"supersecret"` para acceder a una ruta protegida.
|
||||
|
||||
```Python
|
||||
|
|
@ -135,4 +135,3 @@ API_KEY = "supersecret"
|
|||
API_KEY_NAME = "X-API-Key"
|
||||
|
||||
api_key_header = APIKeyHeader(name=API_KEY_NAME, auto_error=False)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue