我正在编写一个错误处理程序来处理令牌刷新。当我收到expired_token
错误时,我正在刷新令牌,我想重播请求,但我不确定如何
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;
}
}
}
刷新令牌后,我可以访问刚刚抛出过期令牌错误的 HttpCall 对象。我想重播请求并替换响应,但我不知道该怎么做。
如何在 Flurl 中重放来自 HttpCall 的请求?