Skip to content
Merged
Show file tree
Hide file tree
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 social_core/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import base64
import re
import time
import uuid
import warnings
from datetime import datetime, timedelta, timezone
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions social_core/tests/backends/test_dummy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import datetime
import json
import time

from httpretty import HTTPretty

Expand Down Expand Up @@ -121,9 +120,7 @@ class ExpirationTimeTest(DummyOAuth2Test):
"first_name": "Foo",
"last_name": "Bar",
"email": "[email protected]",
"expires": time.mktime(
(datetime.datetime.now(datetime.timezone.utc) + DELTA).timetuple()
),
"expires": (datetime.datetime.now() + DELTA).timestamp(),
}
)

Expand Down
Loading