[BUG] Authorization header is not sent through swagger
See original GitHub issueIt seems that swagger interface cannot send Authorization header.
I added test_auth
endpoint with required header authorization
like that:
async def check_auth(
authorization: str = Header(...)
):
pass
@router.post("/test_auth")
async def test_auth(
auth = Depends(check_auth)
):
pass
This works perfectly if I use REST-client with set Authorization header. But, if I use swagger UI it seems that Authorization header always missing. Server responses with status code 422 and:
"detail": [
{
"loc": [
"header",
"authorization"
],
"msg": "field required",
"type": "value_error.missing"
}
]
}
Another observation is if I change the header name to something else (not authorization) it works. But my goal is using Authorization…
FastAPI version: 0.49.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Authorization Header not being sent from Swagger UI 5.0 ...
The generated UI won't have Authorization fields in each endpoint. There should be open locks on the endpoints that had a security requirement ......
Read more >Why is the Authorization header missing in requests sent ...
When testing the request (I clicked on "Authorize" button at the top right and entered my token) I get following error: "error": "Authorization...
Read more >Authorization header not sent by swagger-ui
Hello, I'm trying to configure swagger-ui to send a Basic Auth authorization header. I'm not have any luck so far. ... apiKeyName: "Authorization",...
Read more >Auth token is not passing through header - the Tyk community
I am trying to use the Authorization token in my swagger JSON documentation. My APIs are already using Bearer tokens for their ...
Read more >API Keys
You can define the 401 “Unauthorized” response returned for requests with missing or invalid API key. This response includes the WWW-Authenticate header, which ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/tiangolo/fastapi/blob/55afb70b3717969565499f5dcaef54b1f0acc7da/tests/test_security_http_bearer.py#L7-L12
Not sure if you have read: https://github.com/tiangolo/fastapi/issues/612#issuecomment-547886504