If you need to set an authorization header with a bearer token you can set this in your Startup.cs file (for .NET 6 in Program.cs) like below:
var token = await userApi.GetToken();
builder.Services.AddRefitClient<IFooClient>(new RefitSettings()
{
AuthorizationHeaderValueGetter = () =>
Task.FromResult(token)
}).ConfigureHttpClient(c =>
{
c.BaseAddress = new Uri(builder.Configuration["ApiUri"]);
});
İlk Yorumu Siz Yapın