Skip to content

Commit

Permalink
Merge pull request #634 from princekhunt/master
Browse files Browse the repository at this point in the history
Fix: fix token expiration check for proactive refreshing
  • Loading branch information
lepture authored Apr 8, 2024
2 parents f18c816 + 650748c commit 5424190
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions authlib/oauth2/rfc6749/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ def __init__(self, params):
int(params['expires_in'])
super().__init__(params)

def is_expired(self):
def is_expired(self, leeway=60):
expires_at = self.get('expires_at')
if not expires_at:
return None
return expires_at < time.time()
# small timedelta to consider token as expired before it actually expires
expiration_threshold = expires_at - leeway
return expiration_threshold < time.time()

@classmethod
def from_dict(cls, token):
Expand Down

0 comments on commit 5424190

Please sign in to comment.