Skip to content

Latest commit

 

History

History
93 lines (56 loc) · 3.67 KB

auth0blazorserver.md

File metadata and controls

93 lines (56 loc) · 3.67 KB

Auth0 Blazor Server Application

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

Using the .NET CLI

To create a new Blazor Server application with the .NET CLI, you can run the following command:

dotnet new auth0blazorserver [options]

This will create a new Blazor Server 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 auth0blazorserver -o MyBlazorServer

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

The template "Auth0 Blazor Server 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.
  • -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 auth0blazorserver -o MyBlazorServer --domain myapp.auth0.com --client-id uw63N1fx43yQUwD7Xp4eq9BjKhPeW0dK

Using Visual Studio for Windows

To create a new Blazor Server application with Visual Studio for Windows, select Auth0 from the project types dropdown list and then Auth0 Blazor Server 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 Server application with JetBrains Rider, select Auth0 Blazor Server App from the Custom Templates list, expand the Advanced Settings section, and provide the required options:

Auth0 Blazor Server 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