I want to add "Authorization" header to the my FastAPI application. I did it by documentation, but when i try to execute request in the swagger - it doesn't work(swagger don't use custom header), i have "Missing Authorization Header" error Error in the swagger
That is because OpenAPI specs restrict you from declaring Authorization
header. Other headers that are restricted are Accept
and Content-Type
. Use HTTPBearer
instead.
Source: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#fixed-fields-10