From d76d1ffab788035e488ff1e48c94e4531fa00f08 Mon Sep 17 00:00:00 2001 From: Matthew Chieco Date: Mon, 9 Jun 2025 11:08:25 -0400 Subject: [PATCH] bugfix: subtract timedelta of one minute from app auth flows --- githubkit/auth/app.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/githubkit/auth/app.py b/githubkit/auth/app.py index d187042f2..5b01fbc28 100644 --- a/githubkit/auth/app.py +++ b/githubkit/auth/app.py @@ -212,9 +212,13 @@ def sync_auth_flow( response.read() response = self._parse_installation_auth_response(response) token = response.parsed_data.token - expire = datetime.strptime( - response.parsed_data.expires_at, "%Y-%m-%dT%H:%M:%SZ" - ).replace(tzinfo=timezone.utc) - datetime.now(timezone.utc) + expire = ( + datetime.strptime( + response.parsed_data.expires_at, "%Y-%m-%dT%H:%M:%SZ" + ).replace(tzinfo=timezone.utc) + - datetime.now(timezone.utc) + - timedelta(minutes=1) + ) cache.set(key, token, expire) request.headers["Authorization"] = f"token {token}" yield request @@ -250,9 +254,13 @@ async def async_auth_flow( await response.aread() response = self._parse_installation_auth_response(response) token = response.parsed_data.token - expire = datetime.strptime( - response.parsed_data.expires_at, "%Y-%m-%dT%H:%M:%SZ" - ).replace(tzinfo=timezone.utc) - datetime.now(timezone.utc) + expire = ( + datetime.strptime( + response.parsed_data.expires_at, "%Y-%m-%dT%H:%M:%SZ" + ).replace(tzinfo=timezone.utc) + - datetime.now(timezone.utc) + - timedelta(minutes=1) + ) await cache.aset(key, token, expire) request.headers["Authorization"] = f"token {token}" yield request