freezegun
freezegun copied to clipboard
Freezegun 0.3.13 FakeDateTime cannot be processed properly by JWT
# Payload
for time_claim in ["exp", "iat", "nbf"]:
# Convert datetime to a intDate value in known time-format claims
if isinstance(payload.get(time_claim), datetime):
payload[time_claim] = timegm(
payload[time_claim].utctimetuple()
) # type: ignore
from https://github.com/jpadilla/pyjwt/blob/master/jwt/api_jwt.py#L64
Although the UTC time tuple appears to show minutes correctly, the timestamp returned by timegm here does not include the minutes.
This code works correctly with freezegun 0.3.12.
More info here: https://github.com/spulec/freezegun/issues/327