diff --git a/coretex/networking/network_manager_base.py b/coretex/networking/network_manager_base.py index f75a9faa..50a4f867 100644 --- a/coretex/networking/network_manager_base.py +++ b/coretex/networking/network_manager_base.py @@ -195,7 +195,7 @@ def request( headers = headers ) - response = NetworkResponse(rawResponse) + response = NetworkResponse(rawResponse, endpoint) if response.hasFailed(): logRequestFailure(endpoint, response) @@ -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() diff --git a/coretex/networking/network_response.py b/coretex/networking/network_response.py index fd2915a0..d3936ccd 100644 --- a/coretex/networking/network_response.py +++ b/coretex/networking/network_response.py @@ -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: