为什么如果我在自定义 DelegatingHandler 中将带有正确令牌的授权标头添加到没有此标头的请求中,我会收到响应:需要 401 授权?
public class ProxyHandler : DelegatingHandler
{
protected async override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
request.Headers.Add("Authorization", "Bearer rightToken...");
return response = await base.SendAsync(request, cancellationToken);
}
}