diff options
author | 2021-01-08 16:43:39 +0000 | |
---|---|---|
committer | 2021-01-08 16:43:39 +0000 | |
commit | 542cdc023629513c6d280e2bf96d5d554baa78d9 (patch) | |
tree | 0567a805206c5c8f028a407365f9d891cd02d9af | |
parent | Un-comment out task start (diff) |
Move renewal window to a const
-rw-r--r-- | bot/exts/evergreen/game.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bot/exts/evergreen/game.py b/bot/exts/evergreen/game.py index fe5fc612..be4fcbc9 100644 --- a/bot/exts/evergreen/game.py +++ b/bot/exts/evergreen/game.py @@ -23,6 +23,9 @@ BASE_URL = "https://api.igdb.com/v4" CLIENT_ID = Tokens.igdb_client_id CLIENT_SECRET = Tokens.igdb_client_secret +# The number of seconds before expiry that we attempt to re-fetch a new access token +ACCESS_TOKEN_RENEWAL_WINDOW = 60*60*24*2 + # URL to request API access token OAUTH_URL = "https://id.twitch.tv/oauth2/token" @@ -168,8 +171,8 @@ class Games(Cog): self.access_token = result["access_token"] - # Set next renewal to 2 days before expire time - next_renewal = result["expires_in"] - 60*60*24*2 + # Attempt to renew before the token expires + next_renewal = result["expires_in"] - ACCESS_TOKEN_RENEWAL_WINDOW time_delta = timedelta(seconds=next_renewal) logger.info(f"Successfully renewed access token. Refreshing again in {time_delta}") |