Skip to content

Commit

Permalink
[policies|auth] Move away from deprecated datetime.utcnow
Browse files Browse the repository at this point in the history
Change calls to deprecated datetime.utcnow to datetime.now.

Signed-off-by: Jose Castillo <[email protected]>
  • Loading branch information
jcastill committed Oct 28, 2024
1 parent 2aa4fcf commit c497b7a
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit c497b7a

Please sign in to comment.