Skip to content

Commit

Permalink
Hotfix: API token refresh infinite recursion fix if refresh token is …
Browse files Browse the repository at this point in the history
…invalid/expired
  • Loading branch information
dule1322 committed Nov 30, 2023
1 parent 0a0de91 commit a818c5d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions coretex/networking/network_manager_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def request(
headers = headers
)

response = NetworkResponse(rawResponse)
response = NetworkResponse(rawResponse, endpoint)
if response.hasFailed():
logRequestFailure(endpoint, response)

Expand Down Expand Up @@ -569,7 +569,8 @@ def shouldRetry(self, retryCount: int, response: Optional[NetworkResponse]) -> b

if response is not None:
# If we get unauthorized maybe API token is expired
if response.isUnauthorized():
# If refresh endpoint failed with unauthorized do not retry
if response.isUnauthorized() and response.endpoint != REFRESH_ENDPOINT:
refreshTokenResponse = self.refreshToken()
return not refreshTokenResponse.hasFailed()

Expand Down
5 changes: 4 additions & 1 deletion coretex/networking/network_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ class NetworkResponse:
----------
response : Response
python.requests HTTP reponse
endpoint : str
endpoint to which the request was sent
"""

def __init__(self, response: Response):
def __init__(self, response: Response, endpoint: str):
self._raw = response
self.endpoint = endpoint

@property
def statusCode(self) -> int:
Expand Down

0 comments on commit a818c5d

Please sign in to comment.