Loran
Loran

Reputation: 842

Add Bearer Keywork in Swagger SECURITY_DEFINITIONS

I am trying to use JWT in Django and swagger.

here is my swagger setting

'SECURITY_DEFINITIONS': {
        'JWT': {
            'type': 'apiKey',
            'name': 'Authorization',
            'in': 'header',                  
        }
    },

Current URL format : curl -X GET "http://localhost:8000/api/customer/" -H "accept: application/json" -H "Authorization eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjAzMTIyMzYyLCJqdGkiOiJkNzZhNWIwYTE1MmQ0ZWZlODZiN2E4ZTUzYWQ4NTA3YyIsInVzZXJfaWQiOjF9.8IdlDh"

I would like to add Bearer keyword as prefix of apikey.How can I add that?

Upvotes: 1

Views: 1236

Answers (1)

Yeni Hernandez Orozco
Yeni Hernandez Orozco

Reputation: 11

You should used like this:

'SECURITY_DEFINITIONS': {
        'JWT': {
            'type': 'http',
            'scheme': 'Bearer'
            'in': 'header',                  
        }
    },

here is de doc: https://swagger.io/docs/specification/authentication/bearer-authentication/

Upvotes: 1

Related Questions