FastAPI swagger don't use custom header

Question:

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

Asked By: Ilia

||

Answers:

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

Answered By: Eli Halych
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.