I'm writing an error handler to handle token refreshes. When I get an expired_token
error I'm refreshing the token and I'd like to replay the request but I'm not sure of how
public async Task HandleErrorAsync(HttpCall call)
{
var exception = call.Exception;
if (exception is FlurlHttpException)
{
FlurlHttpException ex = (exception as FlurlHttpException);
var errorResponse = await ex.GetResponseJsonAsync<ErrorResponse>();
if(errorResponse.Errors.Any(x => x.Id == EXPIRED_TOKEN))
{
await this.RefreshOAuthToken();
//How can I Replay the request
//call.Response = call.Request.Replay();
call.ExceptionHandled = true;
}
}
}
After I refresh the token I have access to the HttpCall Object which just threw the expired token error. I'd like to replay the request and replace the response but I 'm not sure of how to do that.
How can I replay a request from an HttpCall in Flurl?
I found an overload to generically send my request, I made an extension method