Skip to content

Commit

Permalink
#2 apply suggestion by @jmcs
Browse files Browse the repository at this point in the history
  • Loading branch information
hjacobs committed Feb 3, 2016
1 parent 6f7c026 commit 91292f4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tokens/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ def get(token_name):
if not access_token or time.time() > token['expires_at'] - REFRESH_BEFORE_SECS_LEFT:
try:
token = refresh(token_name)
access_token = token.get('access_token')
except Exception as e:
if access_token and time.time() < token['expires_at'] + EXPIRATION_TOLERANCE_SECS:
# apply some tolerance, still try our old token if it's still valid
logger.warn('Failed to refresh access token "%s" (but it is still valid): %s', token_name, e)
else:
raise

access_token = token.get('access_token')
return access_token

0 comments on commit 91292f4

Please sign in to comment.