django-rest-swagger
django-rest-swagger copied to clipboard
How to integrate swagger with JWT?
Is it possible to use django-rest-swagger with JSON web tokens?
I've perused the documentation and open issues and many people have examples using 'rest_framework.authentication.TokenAuthentication' in their DEFAULT_AUTHENTICATION_CLASSES but I have not seen any examples for 'rest_framework_jwt.authentication.JSONWebTokenAuthentication'.
Is this functionality part of the project or has this not been implemented yet?
For example this is what I am trying to achieve: REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework_jwt.authentication.JSONWebTokenAuthentication', ), }
SWAGGER_SETTINGS = { 'SECURITY_DEFINITIONS': { 'basic': {'type': 'apiKey'}, 'api_key': { 'type': 'apiKey', 'in': 'header', 'name': 'Authorization' } } }
Also, I do not see the Authorization parameter in my requests with the above method, which seems to be noted by another user commenting on this issue: https://github.com/marcgibbons/django-rest-swagger/issues/708.
2.2.0 is having issue to include token in header. I have same above config, working for 2.1.2 but not 2.2.0
Hello!
After the new version of OpenAPI it should now be possible to speficy JWT authentification like this:
{ "type": "http", "scheme": "bearer", "bearerFormat": "JWT", }
But if I do so I get a 'Unknown security definition type http' error.
I would be very grateful if you could add those changes so that Django REST Swagger is compliant to the new OpenAPI 3.0 spec.
It is bad and I used django-rest-swagger==2.1.2. Can you show me your configuration? this is my versions: djangorestframework==3.6.4 djangorestframework-jwt==1.11.0 django-rest-swagger==2.1.2
Think you.
Any update on this topic ?
For people looking for a solution, my currently working setup for djangorestframework-simplejwt
:
1- Use django-rest-swagger==2.1.2 with:
'SECURITY_DEFINITIONS': {
'api_key': {
'type': 'apiKey',
'in': 'header',
'name': 'Authorization'
}
}
2- As a value after clicking on the Authorize
button : 'Bearer yourAccessToken'
The UI is way better on the 2.2.0 so I can't wait for an update here.
Thanks @JejeDurden it works perfectly fine!