DJANGO REST KNOX EXPIRED

Viewed 33

I use django rest knox I would not like my session to expire when using my app

  'SECURE_HASH_ALGORITHM': 'cryptography.hazmat.primitives.hashes.SHA512',
  'AUTH_TOKEN_CHARACTER_LENGTH': 64,
  'TOKEN_TTL': timedelta(hours=0.0166667),
  'USER_SERIALIZER': 'knox.serializers.UserSerializer',
  'TOKEN_LIMIT_PER_USER': None,
  'AUTO_REFRESH': True,
#   'EXPIRY_DATETIME_FORMAT': api_settings.DATETME_FORMAT
}```
1 Answers

The documentation says

TOKEN_TTL This is how long a token can exist before it expires. Expired tokens are automatically removed from the system.

The setting should be set to an instance of datetime.timedelta. The default is 10 hours ()timedelta(hours=10)).

Setting the TOKEN_TTL to None will create tokens that never expire.

So, to achieve your goal set the TOKEN_TTL = None

Related