Why I can not see the authorize button in drf-spectacular's swagger?

Before we had a monolyth, but now we are moving to microservices architecture, and here the settings for my drf-spectacular, but I do not have the Authorize button as I had before, exactly with this settings just instead of custom authentication was rest_framework_simplejwt.authentication.JWTAuthentication,

REST_FRAMEWORK = {
    'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
    'DEFAULT_AUTHENTICATION_CLASSES': ('custom.custom_authentication.CustomAuthentication',),
}
SPECTACULAR_SETTINGS = {
    'TITLE': 'My Title',
    'DESCRIPTION': 'My description',
    'VERSION': '0.0.1',
    'SERVE_INCLUDE_SCHEMA': False,
    'SERVE_PERMISSIONS': ['rest_framework.permissions.IsAdminUser'],
    'SERVE_AUTHENTICATION': [
        'rest_framework.authentication.SessionAuthentication',
        'custom.custom_authentication.CustomAuthentication',
    ],
    'SWAGGER_UI_SETTINGS': {"filter": True, "persistAuthorization": True}
}

What might be the problem for not seeing the authorize button?

Upvotes: 4

Views: 241

Answers (1)

Michael Mestas
Michael Mestas

Reputation: 1

Try adding DEFAULT_PERMISSION_CLASSES to the rest framework variables in the settings.py file:

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.IsAuthenticated',
    ],
    # ...
}

Upvotes: 0

Related Questions