diff --git a/Conductor/Client/ApiClient.cs b/Conductor/Client/ApiClient.cs index c89e76d..8de5de7 100644 --- a/Conductor/Client/ApiClient.cs +++ b/Conductor/Client/ApiClient.cs @@ -167,11 +167,9 @@ public Object CallApi( String contentType, Configuration configuration = null) { RestResponse response = null; - bool isRetried = false; bool isTokenRefreshed = false; do { - isRetried = false; var request = PrepareRequest( path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, contentType); @@ -181,15 +179,19 @@ public Object CallApi( if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { var JsonContent = JsonConvert.DeserializeObject(response.Content); + if (JsonContent["error"].ToString() == "EXPIRED_TOKEN" && !isTokenRefreshed) { string refreshToken = configuration.GetRefreshToken(); headerParams["X-Authorization"] = refreshToken; - isRetried = true; isTokenRefreshed = true; } + else + isTokenRefreshed = false; } - } while (isRetried); + else + isTokenRefreshed = false; + } while (isTokenRefreshed); return (Object)response; }