I have a problem with Blazor with authentication,

Viewed 50

I have a problem with Blazor with authentication, I created a new Blazor WebAssembly project, Authentication + Hosting Core option.

I removed the Authenticated attribute in FetchData.razor and WeatherForecastController.cs

But I get AccessTokenNotAvailableException error.

Question why am I getting this error?

1 Answers

replace

builder.Services.AddHttpClient("BlazorApp6.ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress))
.AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();

with

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

in client side program file

Related