HttpClient not attaching token

Lex K
31
Reputation points
I'm working on a Blazor app, where I want to use a separate service to do all the API calls. However, this service, even though it has the httpClient in the constructor doesn't seem to have the token passed in.
My Program.cs code:
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddHttpClient<IUserAdminService, UserAdminService>
("userClient", client => client.BaseAddress = new Uri("https://localhost:5011")).AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();
builder.Services.AddOidcAuthentication(options =>
{
builder.Configuration.Bind("Auth0", options.ProviderOptions);
options.ProviderOptions.ResponseType = "code";
options.ProviderOptions.AdditionalProviderParameters.Add("audience", "[audience]");
});
When I log in, I can see a call being done to get the token, but for some reason its not on the HTTP client in the services.
I'm currently using the latest preview of blazor dotnet 6
{count} votes