Skip to content

Commit

Permalink
fix: Assume expiration_timestamp is utc (#135)
Browse files Browse the repository at this point in the history
Co-authored-by: Konstantin <konstantin.klein+github@hochfrequenz.de>
  • Loading branch information
hf-kklein and Konstantin authored Oct 9, 2024
1 parent 3262a2c commit a919f25
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/tmdsclient/client/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def token_is_valid(token: str) -> bool:
try:
decoded_token = jwt.decode(token, algorithms=["HS256"], options={"verify_signature": False})
expiration_timestamp = decoded_token.get("exp")
expiration_datetime = datetime.fromtimestamp(expiration_timestamp)
expiration_datetime = datetime.fromtimestamp(expiration_timestamp).replace(tzinfo=UTC)
_logger.debug("Token is valid until %s", expiration_datetime.isoformat())
current_datetime = datetime.now(UTC)
token_is_valid_one_minute_into_the_future = expiration_datetime > current_datetime + timedelta(minutes=1)
Expand Down

0 comments on commit a919f25

Please sign in to comment.