Search code examples
djangodjango-rest-frameworkdjango-rest-auth

Expire a token in 24 hours - django-rest-knox


I am using django-rest-knox for token authentication in my Django REST Framework app. What I want is to make the token expire only if 24 hours are passed. Is there any setting that it can make this thing happen. Thanks


Solution

  • In settings.py you should do:

    from datetime import timedelta
    
    REST_KNOX = {'TOKEN_TTL': timedelta(hours=24)}