Skip to content

Commit 6ceda9a

Browse files
authored
Reduce access_token refresh margin delay from 2 days to 10 minutes (#76)
Starting on March 4, 2025, a Trakt OAuth `access_token` will expire in 24 hours, instead of 3 months. The current logic is to refresh the `access_token` if its expiration date is within next 2 days. With current code, a 24h token would be immediately refreshed after being fetched. We do not want that. This PR changes this delay from 2 days to 10 minutes. >Why 10 minutes ? This is a margin to be sure the token does not expire in the middle of a critical action such as a list sync/fetch/post. It could be any other delay, but not bigger than 24h. Refs : - trakt/trakt-api#495
2 parents 81b716b + 8d135af commit 6ceda9a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

trakt/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def validate_token(self):
214214

215215
current = datetime.now(tz=timezone.utc)
216216
expires_at = datetime.fromtimestamp(self.config.OAUTH_EXPIRES_AT, tz=timezone.utc)
217-
if expires_at - current > timedelta(days=2):
217+
if expires_at - current > timedelta(minutes=10):
218218
self.OAUTH_TOKEN_VALID = True
219219
else:
220220
self.refresh_token()

0 commit comments

Comments
 (0)