Add Auth0 Authentication to Blazor Web Apps

Hey @chadwick.posey,
Sorry, I missed to suggest that you need to use your client secret to get an access token, as this example from the SDK docs shows.

Keep in mind that the Blazor solution contains two projects: a Blazor Server project and a Blazor WASM project. The project that communicates with Auth0 is the Blazor Server project. This is not a SPA application and so you can use the secret for the Authorization Code Flow without any problem.

Getting an access token this way is meant for calling an external API, that is an API that is not implemented in this Blazor solution. That API must be called by your server code, not by your WASM client.

If you need that your Blazor WASM client calls an API implemented by the Blazor Server in this solution, I suggest using the classical cookie based approach, as mentioned here.

As you said, this article is intended for Auth0. However, I think that the general approach should be valid regardless of the specific Identity provider.

Finally, I agree with you: there is not much documentation for Blazor authentication in .NET 8; it is not covered well by the official documentation either.