Skip to content

Latest commit

 

History

History
105 lines (63 loc) · 4.42 KB

auth0blazorwasm.md

File metadata and controls

105 lines (63 loc) · 4.42 KB

Auth0 Blazor WebAssembly Application

For more information about creating and securing a Blazor WebAssembly application with Auth0, check out the Auth0 Blazor WebAssembly Tutorial.

Using the .NET CLI

To create a new Blazor WebAssembly (ASP.NET Core hosted) application with the .NET CLI, you can run the following command:

dotnet new auth0blazorwasm [options]

This will create a new Blazor WebAssembly application with Auth0 authentication in the current folder.

Automatic registration

If you have the Auth0 CLI installed on your machine and logged in to Auth0, you can run the template command without any options and it will automatically register and configure your application with Auth0.

Example:

dotnet new auth0blazorwasm -o MyBlazorWasm

The template engine will ask for confirmation to perform the registration action:

The template "Auth0 Blazor WebAssembly App" was created successfully.

Processing post-creation actions...

Template is configured to run the following action:
Actual command: register-with-auth0.cmd 
Do you want to run this action [Y(yes)|N(no)]?

Once you confirm, you will get an entry for the application in your current Auth0 tenant and your application will be configured accordingly.

Manual registration

In addition to the usual options for the dotnet new command, the following template-specific options are available:

  • --domain
    The Auth0 domain associated with your tenant. The default value is yourdomain.auth0.com.
  • --client-id
    The client id associated with your application. The default value is your-client-id.
  • --audience
    The API identifier (audience) as defined in your Auth0 dashboard. The default value is https://your-api-id.com.
  • -f or --framework
    Defines the target framework to use for the .NET project. Currently, the only possible value is net7.0, which is also the default value.

Example:

dotnet new auth0blazorwasm -o MyBlazorWasm --domain myapp.auth0.com --client-id uw63N1fx43yQUwD7Xp4eq9BjKhPeW0dK --audience https://myapi.com

Using Visual Studio for Windows

To create a new Blazor WebAssembly application with Visual Studio for Windows, select Auth0 from the project types dropdown list and then Auth0 Blazor WebAssembly App:

Auth0 Blazor Server Application from Visual Studio

Then, after inserting the name and the folder for the project, provide the required options:

Auth0 Blazor Server Application options from Visual Studio

Using Visual Studio for Mac

To create a new Blazor WebAssembly application with Visual Studio for Mac, select Custom from the Other project types list and then Auth0 Blazor WebAssembly App:

Auth0 Blazor Server Application from Visual Studio

Then, after inserting the name and the folder for the project, provide the required options:

Auth0 Blazor Server Application options from Visual Studio

Using JetBrains Rider

To create a new Blazor WebAssembly application with JetBrains Rider, select Auth0 Blazor WebAssembly App from the Custom Templates list, expand the Advanced Settings section, and provide the required options:

Auth0 Blazor WebAssemby Application from JetBrains Rider

Automatic registration

Unfortunately, Visual Studio and Rider do not support template's post actions (see this issue and this one) so your application will not be automatically registered as it happens with .NET CLI. However, you can run the post action manually to get your application configured.

To launch the automatic registration process, go to the folder of the newly created application and run the following command:

./register-with-auth0.cmd

Note: on MacOS you need to enable the script to execute. Run the following command before launching the automatic registration:

chmod +x register-with-auth0.cmd

Back to README