Skip to content

Commit cdd9857

Browse files
fix: Timezone changes in toke_auth_strategy.py (#848)
Co-authored-by: Shubham <[email protected]>
1 parent 807f380 commit cdd9857

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

twilio/auth_strategy/token_auth_strategy.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import jwt
22
import threading
33
import logging
4-
from datetime import datetime
4+
from datetime import datetime, timezone
55

66
from twilio.auth_strategy.auth_type import AuthType
77
from twilio.auth_strategy.auth_strategy import AuthStrategy
@@ -43,8 +43,8 @@ def is_token_expired(self, token):
4343
if exp is None:
4444
return True # No expiration time present, consider it expired
4545

46-
# Check if the expiration time has passed
47-
return datetime.fromtimestamp(exp) < datetime.utcnow()
46+
# Check if the expiration time has passed by using time-zone
47+
return datetime.fromtimestamp(exp, tz = timezone.utc) < datetime.now(timezone.utc)
4848

4949
except jwt.DecodeError:
5050
return True # Token is invalid

0 commit comments

Comments
 (0)