really need some help to understand what I'm doing wrong with my reauthorization policy.
My policy looks like this:
var policy = Policy
.HandleResult<HttpResponseMessage>(message => message.StatusCode == HttpStatusCode.Unauthorized)
.RetryAsync(1, async (result, retryCount) =>
{
await _authorizeService.RefreshAccessToken();
RestEaseClient.Token = _authorizeService.AccessToken;
});
And IRestEaseClient looks like this:
public interface IRestEaseClient
{
[Header("X-Token")]
string Token { get; set; }
["root")]
Task SomeMethod();
.................
}
When the token expires the breakpoint inside the policy retry function gets hit, I successfully receive the new token, set its value to IRestEaseClient.Token header, but for some reason, the retry request goes with the old header value and I still get 401. The next request after this will go fine, without 401 or hitting the reauthorize policy code.