Skip to content

Timezone changes in toke_auth_strategy.py #848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions twilio/auth_strategy/token_auth_strategy.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading