diff --git a/frappe/integrations/doctype/token_cache/token_cache.py b/frappe/integrations/doctype/token_cache/token_cache.py index b01974e5ab..034b1d9107 100644 --- a/frappe/integrations/doctype/token_cache/token_cache.py +++ b/frappe/integrations/doctype/token_cache/token_cache.py @@ -52,11 +52,10 @@ class TokenCache(Document): return self def get_expires_in(self): + modified = frappe.utils.get_datetime(self.modified) + expiry_utc = modified.astimezone(pytz.utc) + timedelta(seconds=self.expires_in) now_utc = datetime.utcnow().replace(tzinfo=pytz.utc) - expiry_time = frappe.utils.get_datetime(self.modified) + timedelta(seconds=self.expires_in) - expiry_local = expiry_time.replace(tzinfo=pytz.timezone(frappe.utils.get_time_zone())) - expiry_utc = expiry_local.astimezone(pytz.utc) - return (expiry_utc - now_utc).total_seconds() + return cint((expiry_utc - now_utc).total_seconds()) def is_expired(self): return self.get_expires_in() < 0