Thank you for reaching out to Microsoft Q & A forum.
The error "IAccessTokenProvider not registered" usually indicates that the OIDC authentication services have not been correctly configured in a Blazor WebAssembly project.
To resolve this:
1.Ensure the project is a Blazor WebAssembly app, not a Blazor Server or .NET 9 Blazor Web App (which use a different authentication model).
2.Verify the required package is installed: Microsoft.AspNetCore.Components.WebAssembly.Authentication
3.Ensure authentication services are registered in Program.cs:
builder.Services.AddOidcAuthentication(options =>
{
builder.Configuration.Bind("Oidc", options.ProviderOptions);
options.ProviderOptions.DefaultScopes.Add("api");
});
4.Confirm the OIDC configuration exists in wwwroot/appsettings.json:
"Oidc": {
"Authority": "https://your-auth-server",
"ClientId": "your-client-id",
"ResponseType": "code",
"DefaultScopes": ["openid", "profile", "api"]
}
5.Use BaseAddressAuthorizationMessageHandler when configuring HttpClient to attach the access token automatically.
If the project is based on the new .NET 9 Blazor Web App template, please note that it uses a different authentication approach, and IAccessTokenProvider from WebAssembly is not supported in that model.
If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.