Skip to content

Commit e5149f6

Browse files
Jeff-Meadowsjmoldow
authored andcommitted
Fix JWT Token Refresh (#209)
1 parent 91d67cc commit e5149f6

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

boxsdk/auth/jwt_auth.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,5 +291,7 @@ def _refresh(self, access_token):
291291
"""
292292
# pylint:disable=unused-argument
293293
if self._user_id is None:
294-
return self.authenticate_instance()
295-
return self.authenticate_user()
294+
new_access_token = self.authenticate_instance()
295+
else:
296+
new_access_token = self.authenticate_user()
297+
return new_access_token, None

boxsdk/auth/oauth2.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,11 @@ def refresh(self, access_token_to_refresh):
203203
# The lock here is for handling that case that multiple requests fail, due to access token expired, at the
204204
# same time to avoid multiple session renewals.
205205
if (access_token is None) or (access_token_to_refresh == access_token):
206-
# If the active access token is the same as the token needs to
206+
# If the active access token is the same as the token that needs to
207207
# be refreshed, or if we don't currently have any active access
208208
# token, we make the request to refresh the token.
209-
return self._refresh(access_token_to_refresh)
210-
211-
# If the active access token (self._access_token) is not the same as the token needs to be refreshed,
209+
access_token, refresh_token = self._refresh(access_token_to_refresh)
210+
# Else, if the active access token (self._access_token) is not the same as the token needs to be refreshed,
212211
# it means the expired token has already been refreshed. Simply return the current active tokens.
213212
return access_token, refresh_token
214213

0 commit comments

Comments
 (0)