Drf-yasg: JWT Bearer token authentication

Created on 12 Jan 2018  路  1Comment  路  Source: axnsan12/drf-yasg

I tried setting up my Access token in the Authorize field. It didn't work. When I check the curl request there is no header parameter for Authorization. Can someone tell me how to add Bearer Token Auth?

question

Most helpful comment

Hello,

Something like this should work:

SWAGGER_SETTINGS = {
   'SECURITY_DEFINITIONS': {
        'Bearer': {
            'type': 'apiKey',
            'name': 'Authorization',
            'in': 'header'
        }
    }
}

You will have to click the green authorize button in the top right and set the acces token; you will have to add the Bearer prefix manually when setting the token, as OpenAPI 2.0 has no support for authorization header prefixes - e.g. Bearer <token here>

>All comments

Hello,

Something like this should work:

SWAGGER_SETTINGS = {
   'SECURITY_DEFINITIONS': {
        'Bearer': {
            'type': 'apiKey',
            'name': 'Authorization',
            'in': 'header'
        }
    }
}

You will have to click the green authorize button in the top right and set the acces token; you will have to add the Bearer prefix manually when setting the token, as OpenAPI 2.0 has no support for authorization header prefixes - e.g. Bearer <token here>

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Safrone picture Safrone  路  3Comments

nicholasgcoles picture nicholasgcoles  路  4Comments

gertjanol picture gertjanol  路  5Comments

littlehome-eugene picture littlehome-eugene  路  4Comments

iamhssingh picture iamhssingh  路  3Comments