Auth0.OidcClient.MAUI 1.0.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Auth0.OidcClient.MAUI --version 1.0.0
NuGet\Install-Package Auth0.OidcClient.MAUI -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Auth0.OidcClient.MAUI" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Auth0.OidcClient.MAUI --version 1.0.0
#r "nuget: Auth0.OidcClient.MAUI, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Auth0.OidcClient.MAUI as a Cake Addin
#addin nuget:?package=Auth0.OidcClient.MAUI&version=1.0.0

// Install Auth0.OidcClient.MAUI as a Cake Tool
#tool nuget:?package=Auth0.OidcClient.MAUI&version=1.0.0

Auth0.OidcClient.MAUI

Integrate Auth0 in a MAUI application targetting iOS, macOS or Android by using the Auth0.OIdcClient.MAUI SDK.

Install the SDK

The SDK can be installed through Nuget:

Install-Package Auth0.OIdcClient.MAUI

Configuring the SDK

Once the SDK has been installed, you can integrate it by instantiating the Auth0Client:

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

Platform specific configuration

In order to use the SDK with Android and Windows, you need some platform specific configuration.

Android

Create a new Activity that extends WebAuthenticatorCallbackActivity:

[Activity(NoHistory = true, LaunchMode = LaunchMode.SingleTop, Exported = true)]
[IntentFilter(new[] { Intent.ActionView },
              Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
              DataScheme = CALLBACK_SCHEME)]
public class WebAuthenticatorActivity : Microsoft.Maui.Authentication.WebAuthenticatorCallbackActivity
{
    const string CALLBACK_SCHEME = "myapp";
}

The above activity will ensure the application can handle the myapp://callback URL when Auth0 redirects back to the Android application after logging in.

Windows

To make sure it can properly reactivate your application after being redirected back go Auth0, you need to do two things:

  • Add the corresponding protocol to the Package.appxmanifest. In this case, this is set to myapp, but you can change this to whatever you like (ensure to update all relevant Auth0 URLs as well).
    <Applications>
      <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
        <Extensions>
          <uap:Extension Category="windows.protocol">
            <uap:Protocol Name="myapp"/>
          </uap:Extension>
        </Extensions>
      </Application>
    </Applications>
    
  • Call Activator.Default.CheckRedirectionActivation() in the Windows specific App.xaml.cs file.
    public App()
    {
      if (Auth0.OidcClient.Platforms.Windows.Activator.Default.CheckRedirectionActivation())
        return;
    
      this.InitializeComponent();
    }
    

Add login to your application

In order to add login, you can call LoginAsync on the Auth0Client instance.

var loginResult = await client.LoginAsync();

The returned LoginResult indicates whether or not the request was succesful through the IsError property. Incase it was succesful, you can retrieve the user using the LoginResult.User property.

if (loginResult.IsError == false)
{
    var user = loginResult.User
}

Add logout to your application

Logging out of the SDK comes down to calling LogoutAsync on the Auth0Client instance.

await client.LogoutAsync();
Product Compatible and additional computed target framework versions.
.NET net6.0-android29.0 is compatible.  net6.0-ios13.0 is compatible.  net6.0-maccatalyst14.0 is compatible.  net6.0-windows10.0.19041 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-windows was computed.  net8.0-android was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 155 4/29/2024
1.0.0 2,738 1/4/2024
1.0.0-beta.1 216 10/31/2023
1.0.0-beta.0 52 10/30/2023

Version 1.0.0
     - Initial release for adding support for MAUI on Android, iOS, macOS, and Windows.

   Version 1.0.0-beta.1
     - Update README

   Version 1.0.0-beta.0
     - Initial beta release for adding support for MAUI on Android, iOS, macOS, and Windows.