Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bugfix: subtract timedelta of one minute from app auth flows
  • Loading branch information
mchieco committed Jun 9, 2025
commit d76d1ffab788035e488ff1e48c94e4531fa00f08
20 changes: 14 additions & 6 deletions githubkit/auth/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down