diff --git a/social_core/storage.py b/social_core/storage.py index ee3019ff8..392b98003 100644 --- a/social_core/storage.py +++ b/social_core/storage.py @@ -2,7 +2,6 @@ import base64 import re -import time import uuid import warnings from datetime import datetime, timedelta, timezone @@ -71,9 +70,10 @@ def expiration_timedelta(self): now = datetime.now(timezone.utc) # Detect if expires is a timestamp - if expires > time.mktime(now.timetuple()): + if expires > now.timestamp(): # expires is a datetime, return the remaining difference - return datetime.fromtimestamp(expires, tz=timezone.utc) - now + expiry_time = datetime.fromtimestamp(expires, tz=timezone.utc) + return expiry_time - now else: # expires is the time to live seconds since creation, # check against auth_time if present, otherwise return diff --git a/social_core/tests/backends/test_dummy.py b/social_core/tests/backends/test_dummy.py index cb16f5094..49e59923a 100644 --- a/social_core/tests/backends/test_dummy.py +++ b/social_core/tests/backends/test_dummy.py @@ -1,6 +1,5 @@ import datetime import json -import time from httpretty import HTTPretty @@ -121,9 +120,7 @@ class ExpirationTimeTest(DummyOAuth2Test): "first_name": "Foo", "last_name": "Bar", "email": "foo@bar.com", - "expires": time.mktime( - (datetime.datetime.now(datetime.timezone.utc) + DELTA).timetuple() - ), + "expires": (datetime.datetime.now() + DELTA).timestamp(), } )