Skip to content

Commit

Permalink
Refresh token if it will expire within 5 minutes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Pigorsch committed Jun 21, 2020
1 parent 853f158 commit 2fceb04
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def check_access(self):
now = datetime.datetime.fromtimestamp(time.time())
expires_at = datetime.datetime.fromtimestamp(self.authdata["expires_at"])
print(f'Access token valid until {expires_at} (now is {now})')
if now >= expires_at:
if now + datetime.timedelta(minutes=5) >= expires_at:
print("Refreshing access token")
response = self.client.refresh_access_token(
client_id=self.config["client_id"],
Expand Down

0 comments on commit 2fceb04

Please sign in to comment.