From 91292f4d82856d5b11c444edb5e3b5eb6f470918 Mon Sep 17 00:00:00 2001 From: Henning Jacobs Date: Wed, 3 Feb 2016 16:05:39 +0100 Subject: [PATCH] #2 apply suggestion by @jmcs --- tokens/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tokens/__init__.py b/tokens/__init__.py index 4250eaa..80e1ae5 100644 --- a/tokens/__init__.py +++ b/tokens/__init__.py @@ -125,6 +125,7 @@ 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 @@ -132,5 +133,4 @@ def get(token_name): else: raise - access_token = token.get('access_token') return access_token