Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jithesh-poojary committed Feb 23, 2024
1 parent 571fc2a commit a30ca87
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Conductor/Client/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -181,15 +179,19 @@ public Object CallApi(
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
{
var JsonContent = JsonConvert.DeserializeObject<JObject>(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;
}
Expand Down

0 comments on commit a30ca87

Please sign in to comment.