I'm trying to set a HttpMessageHandler for a refit client which adds the Authorization Header to the request, but it's not working after I followed the documentation and multiple github examples.
Here is how I configure it:
services.TryAddTransient<AuthorizationHeaderHandler>();
services.AddRefitClient<IWebApi>()
.ConfigureHttpClient(c => c.BaseAddress = new Uri(Configuration.GetSection("Apis:MyApi:Url").Value))
.AddHttpMessageHandler<AuthorizationHeaderHandler>();
When I use this in the service layer, it gets resolved, but when I try to use it, it doesn't attach any Authorization header. Any thoughts ?