From c497b7a0426d4521a584cbed6d02d34cf6a44745 Mon Sep 17 00:00:00 2001 From: Jose Castillo Date: Mon, 28 Oct 2024 13:11:44 +0000 Subject: [PATCH] [policies|auth] Move away from deprecated datetime.utcnow Change calls to deprecated datetime.utcnow to datetime.now. Signed-off-by: Jose Castillo --- sos/policies/auth/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sos/policies/auth/__init__.py b/sos/policies/auth/__init__.py index 483e3ba5b3..094fa27a6c 100644 --- a/sos/policies/auth/__init__.py +++ b/sos/policies/auth/__init__.py @@ -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): @@ -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): """ @@ -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): """