PWSHub News

Auth0 SDK for .NET Desktop and Mobile Applications Supports MAUI

The .NET MAUI framework allows developers to build desktop and mobile applications running on Windows, macOS, iOS, and Android. You can do it using a single programming language (C#) and a single codebase. Now, you can easily integrate these applications with Auth0 using the Auth0 SDK for .NET Desktop and Mobile Applications.

Meet the .NET MAUI Package

If you have already used the Auth0 SDK for .NET Desktop and Mobile Applications, you may know its internal architecture. The SDK relies on a core library, Auth0.OidcClient.Core, which implements the fundamental functionality of the authentication SDK, and a set of packages that make this functionality available to the several native UI frameworks supported by .NET: WPF, WinForms, UWP, Xamarin. Now the SDK also supports MAUI, completing the full range of UI options natively supported by .NET.

The addition of MAUI support to the SDK significantly simplifies the integration of Auth0 authentication and authorization services with your applications.

Install the SDK

To use the .NET MAUI SDK, you have to install it by running the following command in a terminal window:

dotnet add package Auth0.OidcClient.MAUI

If you use Visual Studio, you can install it through the NuGet Package Manager, as shown in the following picture:

Auth0 MAUI SDK in NuGet package manager

Use the SDK

Using the SDK is pretty straightforward. The first thing to do is to register your application in the Auth0 dashboard. If you don't have an Auth0 account, you can sign up for free.

In your MAUI project, create an instance of the Auth0Client class by providing the configuration parameters taken from the Auth0 dashboard, as shown in the following code snippet:

var client = new Auth0Client(new Auth0ClientOptions()
{
  Domain = "<YOUR_AUTH0_DOMAIN>",
  ClientId = "<YOUR_AUTH0_CLIENT_ID>",
  RedirectUri = "myapp://callback",
  PostLogoutRedirectUri = "myapp://callback",
  Scope = "openid"
});

Then, you can invoke the LoginAsync() method of the client instance to let the user log in:

var loginResult = await client.LoginAsync();

On the other side, you can let the user log out by calling the LogoutAsync() method:

await client.LogoutAsync();

Learn More

Of course, the code shown above represents the very basic usage of the SDK, just to give you a high-level idea of how simple it is to use. In a concrete MAUI application, you must configure it to support the different target platforms and write additional code to handle more complex use cases.

For an example of how to use the MAUI SDK, look at our .NET MAUI Quickstart.

For a more elaborated tutorial, read Add Authentication to .NET MAUI Apps with Auth0. Finally, to learn how to use the MAUI SDK to get access tokens and call an API, check out Call a Protected API from a .NET MAUI App.

If you have any questions or comments about the MAUI SDK, leave a comment below.

Source: auth0.com

Related stories
4 days ago - TL;DR: In mid-February, we released Auth0 Teams- our new parent entity that consolidates managing tenants and tenant members and allows for clearer...
1 week ago - When managing infrastructure for any large enough organization, you will need to automate the provisioning and configuration of resources, services, and applications. Terraform has been the de facto standard for infrastructure as code...
4 days ago - Businesses using Auth0 by Okta’s Universal Login, can leverage a pro-code option to customize signup and login flows to address unique needs.
1 month ago - Your identity platform is critical to growing and scaling your SaaS application. Accelerate business growth and keep your users secured with Auth0 by Okta
Other stories
2 hours ago - Here's a quick set of steps from my actual experiences of using Fedora Linux as daily driver, which you can follow.
7 hours ago - Written by Contributor Opinions expressed by Twilio contributors are their own In this post, we'll learn how to build an...
8 hours ago - In the world of data science, where raw information swirls in a cacophony of numbers and variables, lies the art of harmonizing data. Like a maestro conducting a symphony, the skilled data scientist orchestrates the disparate elements of...
9 hours ago - Windows 10 allows you to create a password lock on a folder so only you can access the content within. Here are the steps to set up a password-locked folder
9 hours ago - Want to mirror your iPhone screen on your Ubuntu desktop? There's a free, open-source app you can install from the Ubuntu repos to do exactly that. If
12 hours ago - Avid users of Varia, a modern download manager for Linux desktops, may want to check out official browser extensions. By installing the official Varia