AuthenticationStateProvider labeling user with access token as unauthenticated

So I am running my Blazor client wasm SPA, along with my .net core web api. When I call my API with the access token that the user has, my API labels the user as authorized. But when I try to use AuthorizeView or the Authorize attribute on my frontend it labels the user as unauthenticated even though a non-expired access token exists in local storage.

I am using auth0’s AuthenticationStateProvider. This is how i am configuring OpenID Authentication va program.cs:

builder.Services.AddOidcAuthentication(options =>
{
    options.ProviderOptions.Authority = $"https://{builder.Configuration["Auth0:Domain"]}";
    options.ProviderOptions.ClientId = builder.Configuration["Auth0:ClientId"];
    options.ProviderOptions.DefaultScopes.Add("openid");
    options.ProviderOptions.DefaultScopes.Add("profile");
    options.ProviderOptions.DefaultScopes.Add("offline_access");
});

Fixed it by making a custom AuthenticationStateProvider

1 Like

Hello @olaskole4405,

Welcome back to the Auth0 community!

Thank you for sharing your solution with the community.

Thanks,
Tudor.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.