Skip to content

Commit a65026d

Browse files
committed
Fix JWT Token Refresh
Fixes #197 in v1.5. Cherry picked from master branch (v2.0.0). (cherry picked from commit e5149f6)
1 parent a1dba2d commit a65026d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

boxsdk/auth/jwt_auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ def _refresh(self, access_token):
193193
"""
194194
# pylint:disable=unused-argument
195195
if self._user_id is None:
196-
return self.authenticate_instance()
196+
new_access_token = self.authenticate_instance()
197197
else:
198-
return self._auth_with_jwt(self._user_id, 'user')
198+
new_access_token = self._auth_with_jwt(self._user_id, 'user')
199+
return new_access_token, None

boxsdk/auth/oauth2.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,13 @@ 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-
else:
211-
# If the active access token (self._access_token) is not the same as the token needs to be refreshed,
212-
# it means the expired token has already been refreshed. Simply return the current active tokens.
213-
return access_token, refresh_token
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,
211+
# it means the expired token has already been refreshed. Simply return the current active tokens.
212+
return access_token, refresh_token
214213

215214
@staticmethod
216215
def _get_state_csrf_token():

0 commit comments

Comments
 (0)