I want to reissue jwt token exp verify in python django

i am developing using django and python. im not using DRF.

I want to extract the exp from the code below and make the token reissue within 7 days of the current date or past the current date.

This is the encoded code

homes_session = jwt.encode({'user_id': user.id, 'exp':datetime.utcnow()+timedelta(days=28)}, SECRET_KEY, ALGORITHM)

This is the decoded code

payload = jwt.decode(homes_session, SECRET_KEY, ALGORITHM)
homes_session_exp=payload["exp"]

if (now - homes_session_exp).days <= 7:

In the decoded payload, when within 7 weeks of the current time or after the current time, I want to customize the jwt to be reissued.

Am I not good at understanding jwt???

Back to Top