From a646c0682b3acf0617536ae9a5f8311571b40dac Mon Sep 17 00:00:00 2001 From: Pablo2113 Date: Thu, 27 Feb 2025 20:02:05 +0100 Subject: [PATCH] Timezone changes in toke_auth_strategy.py --- twilio/auth_strategy/token_auth_strategy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/twilio/auth_strategy/token_auth_strategy.py b/twilio/auth_strategy/token_auth_strategy.py index ee51f05a43..40ee4c80ec 100644 --- a/twilio/auth_strategy/token_auth_strategy.py +++ b/twilio/auth_strategy/token_auth_strategy.py @@ -1,7 +1,7 @@ import jwt import threading import logging -from datetime import datetime +from datetime import datetime, timezone from twilio.auth_strategy.auth_type import AuthType from twilio.auth_strategy.auth_strategy import AuthStrategy @@ -43,8 +43,8 @@ def is_token_expired(self, token): if exp is None: return True # No expiration time present, consider it expired - # Check if the expiration time has passed - return datetime.fromtimestamp(exp) < datetime.utcnow() + # Check if the expiration time has passed by using time-zone + return datetime.fromtimestamp(exp, tz = timezone.utc) < datetime.now(timezone.utc) except jwt.DecodeError: return True # Token is invalid