Drf-yasg: Add DRF Token Auth to swagger

Created on 15 May 2019  路  2Comments  路  Source: axnsan12/drf-yasg

How to add DRF token auth to swagger docs? It is not clear in the document as to how it should be declared.

question

Most helpful comment

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

should be enough. You'll have to manually add the Token prefix (or whatever you set) to the token input in swagger-ui.

All 2 comments

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

should be enough. You'll have to manually add the Token prefix (or whatever you set) to the token input in swagger-ui.

@axnsan12 the class TokenAuthentication from drf already use the Token prefix so it shouldn't be used as default on drf-yasg?
Is there anything in the docs that show how to add the token prefix to the ui input?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marcosgeorgopoulos picture marcosgeorgopoulos  路  4Comments

mkurnikov picture mkurnikov  路  4Comments

nicholasgcoles picture nicholasgcoles  路  4Comments

geekashu picture geekashu  路  5Comments

jaumard picture jaumard  路  5Comments