admin管理员组

文章数量:1400572

That's my YARP configuration:

builder.Services.AddReverseProxy()
    .LoadFromConfig(builder.Configuration.GetRequiredSection("ReverseProxy"))
    .AddTransforms(builder =>
    {
        builder.AddRequestTransform(async (ctx) =>
        {
            var accessToken = await ctx.HttpContext.GetTokenAsync("access_token");
            ctx.ProxyRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
        });
    });

and the problem is I want to refresh my access token when the response for proxied request is 401. Specifically, I want to get new access token using refresh token, set new cookie with new access token and retry request. But I can't find any documented way to do so if I'm using YARP.

本文标签: cHow to refresh access token when proxied request gets 401 response YARPStack Overflow