Flasgger - Add bearer authorization Flasgger - Add bearer authorization flask flask

Flasgger - Add bearer authorization


For adding header in Flasgger API, do the following changes:

SWAGGER_TEMPLATE = {"securityDefinitions": {"APIKeyHeader": {"type": "apiKey", "name": "x-access-token", "in": "header"}}}swagger = Swagger(app, template=SWAGGER_TEMPLATE)

Here, x-access-token is our key name in header. you can change this name according to your requirement.After this, we need to add this header in our .yml file. Our .yml file will look like this:

summary: "Put your summery here."description: "Put your description here."consumes:- "application/json"produces:- "application/json"security:- APIKeyHeader: ['x-access-token']responses:  200:    description: "Success"