From 4873d0d486a9df22b161736a02a74569986d5089 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Fri, 29 Aug 2025 23:03:43 +0200 Subject: [PATCH] fix the expiration time --- .../app/routes/airtable_add_connector_route.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/surfsense_backend/app/routes/airtable_add_connector_route.py b/surfsense_backend/app/routes/airtable_add_connector_route.py index 65ec713a1..2747e3a4f 100644 --- a/surfsense_backend/app/routes/airtable_add_connector_route.py +++ b/surfsense_backend/app/routes/airtable_add_connector_route.py @@ -3,7 +3,7 @@ import hashlib import json import logging import secrets -from datetime import datetime, timedelta +from datetime import UTC, datetime, timedelta from uuid import UUID import httpx @@ -188,8 +188,6 @@ async def airtable_callback( timeout=30.0, ) - logger.info(f"Token response: {token_response.json()}") - if token_response.status_code != 200: error_detail = token_response.text try: @@ -203,10 +201,11 @@ async def airtable_callback( token_json = token_response.json() - # Calculate expiration time + # Calculate expiration time (UTC, tz-aware) expires_at = None if token_json.get("expires_in"): - expires_at = datetime.now() + timedelta(seconds=token_json["expires_in"]) + now_utc = datetime.now(UTC) + expires_at = now_utc + timedelta(seconds=int(token_json["expires_in"])) # Create credentials object credentials = AirtableAuthCredentialsBase(