I'll come straight to the point:
- I create the jwt:
jwt.encode({'sub':"abc", "iat":datetime.now(tz=timezone.utc), "exp":datetime.now()+timedelta(seconds=1)}, JWT_KEY, algorithm="HS256")
- I wait
time.sleep(3)
- I try to validate the
exp
flag:
try:
return jwt.decode(token, JWT_KEY, algorithms=["HS256"])
except jwt.ExpiredSignatureError:
raise Exception("JWT expired")
But it won't raise the desired exception even though the current time is behind the exp timestamp