Skip to content
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

[policies|auth] Move away from deprecated datetime.utcnow #3825

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
8 changes: 4 additions & 4 deletions sos/policies/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ def _set_token_data(self, token_data):
and their expiry etc.
"""
self._access_token = token_data.get("access_token")
self._access_expires_at = datetime.utcnow() + \
self._access_expires_at = datetime.now() + \
timedelta(seconds=token_data.get("expires_in"))
self._refresh_token = token_data.get("refresh_token")
self._refresh_expires_in = token_data.get("refresh_expires_in")
if self._refresh_expires_in == 0:
self._refresh_expires_at = datetime.max
else:
self._refresh_expires_at = datetime.utcnow() + \
self._refresh_expires_at = datetime.now() + \
timedelta(seconds=self._refresh_expires_in)

def get_access_token(self):
Expand All @@ -161,7 +161,7 @@ def is_access_token_valid(self):
"""
return self._access_token and self._access_expires_at and \
self._access_expires_at - timedelta(seconds=180) > \
datetime.utcnow()
datetime.now()

def is_refresh_token_valid(self):
"""
Expand All @@ -173,7 +173,7 @@ def is_refresh_token_valid(self):
"""
return self._refresh_token and self._refresh_expires_at and \
self._refresh_expires_at - timedelta(seconds=180) > \
datetime.utcnow()
datetime.now()

def _use_refresh_token_grant(self, refresh_token=None):
"""
Expand Down
Loading