I have a Django (DRF) project with OAuth2 based on python-social-auth
and Swagger based on drf-spectacular
. I need to integrate these two libraries together so that Swagger allow OAuth2 authorization, for example Google OAuth2. I found OAuth2 configuration for drf-spectacular
in settings:
SPECTACULAR_SETTINGS = {
...
'SWAGGER_UI_OAUTH2_CONFIG': {
...
# Oauth2 related settings. used for example by django-oauth2-toolkit.
# https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#oauth-flows-object
'OAUTH2_FLOWS': [],
'OAUTH2_AUTHORIZATION_URL': None,
'OAUTH2_TOKEN_URL': None,
'OAUTH2_REFRESH_URL': None,
'OAUTH2_SCOPES': None,
},
...
}
But I'm not really sure whether it fits me or not. I wrote this in my version of this config, but it appearently has no effect:
'SWAGGER_UI_OAUTH2_CONFIG': {
'OAUTH2_AUTHORIZATION_URL': 'https://accounts.google.com/o/oauth2/auth',
'OAUTH2_TOKEN_URL': 'https://accounts.google.com/o/oauth2/token',
'OAUTH2_SCOPES': ['openid', 'email', 'profile'],
}
Swagger still has no OAuth2. Any idea how to manage it?