when I authorize myself in Swagger UI, I have to write "Bearer {then I write JWT} here"
How can I add the string "Bearer" automatically before the JWT token in swagger UI? Here is my Swagger Settings:
SWAGGER_SETTINGS = {
"SECURITY_DEFINITIONS": {
"JWT [Bearer {JWT}]": {
"name": "Authorization",
"type": "apiKey",
"in": "header",
}
},
"USE_SESSION_AUTH": False,
}
FORCE_SCRIPT_NAME = "/"
I recommend you to migrate from drf-yasg
to drf_spectacular
, it already includes JWT authentication automatically and without so many complications, it even uses OpenAPI 3 (drf-yasg
uses OpenAPI 2 and is becoming obsolete)
Automatic Generation
Authenticate with JWT
See this From drf-yasg to OpenAPI 3