Skip to content

Latest commit

 

History

History
103 lines (61 loc) · 4.02 KB

auth0maui.md

File metadata and controls

103 lines (61 loc) · 4.02 KB

Auth0 MAUI Application

For more information about creating and securing a MAUI application with Auth0, check out the Add Authentication to .NET MAUI Apps with Auth0 article.

Using the .NET CLI

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

dotnet new auth0maui [options]

This will create a new MAUI 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 auth0maui -o MyMauiApp

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

The template "Auth0 .NET MAUI 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 net8.0, which is also the default value.

Example:

dotnet new auth0maui -o MyMauiApp --domain myapp.auth0.com --client-id uw63N1fx43yQUwD7Xp4eq9BjKhPeW0dK

Using Visual Studio for Windows

To create a new MAUI application with Visual Studio for Windows, select Auth0 from the project types dropdown list and then Auth0 .NET MAUI 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 MAUI application with Visual Studio for Mac, select Custom from the Other project types list and then Auth0 .NET MAUI 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 MAUI application with JetBrains Rider, select Auth0 .NET MAUI 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