Error in setting SIGNING_KEY in djangorestframework-simplejwt

24 Views Asked by At

It's a bit odd! I have separated the base settings from the local settings. For instance, I moved SECRET_KEY into an other file called local.py as my local settings:

SECRET_KEY = env(
    "DJANGO_SECRET_KEY",
    default="MY_DEFAULT_SEC_KEY"
)

and the following is my simple-jwt settings in base.py which does not contain any variable called SECRET_KEY(since I moved it into local.py):

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

SIMPLE_JWT = {
    "AUTH_HEADER_TYPES": ("Bearer", ),
    "ACCESS_TOKEN_LIFETIME": timedelta(minutes=30),
    "REFRESH_TOKEN_LIFETIME": timedelta(days=1),
    "ROTATE_REFRESH_TOKENS": True,
    "SIGNING_KEY": env("SIGNING_KEY"),
    "USER_ID_FIELD": "id",
    "USER_ID_CLAIM": "user_id",
}

I want to set a different SIGNING_KEY but I get the following error:

File "/usr/local/lib/python3.11/site-packages/rest_framework_simplejwt/settings.py", line 19, in celery_worker-1 | "SIGNING_KEY": settings.SECRET_KEY, celery_worker-1 |
^^^^^^^^^^^^^^^^^^^ celery_worker-1 | File "/usr/local/lib/python3.11/site-packages/django/conf/init.py", line 111, in getattr celery_worker-1 | raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.") celery_worker-1 | django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

I don't need to set SECRET_KEY according to the documentation when I set a different SIGNING_KEY. However, it says I need to give it a value. What is the problem?

0

There are 0 best solutions below