Auth0.OidcClient.MAUI
1.0.1
Prefix Reserved
dotnet add package Auth0.OidcClient.MAUI --version 1.0.1
NuGet\Install-Package Auth0.OidcClient.MAUI -Version 1.0.1
<PackageReference Include="Auth0.OidcClient.MAUI" Version="1.0.1" />
paket add Auth0.OidcClient.MAUI --version 1.0.1
#r "nuget: Auth0.OidcClient.MAUI, 1.0.1"
// Install Auth0.OidcClient.MAUI as a Cake Addin #addin nuget:?package=Auth0.OidcClient.MAUI&version=1.0.1 // Install Auth0.OidcClient.MAUI as a Cake Tool #tool nuget:?package=Auth0.OidcClient.MAUI&version=1.0.1
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 tomyapp
, 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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-android29.0 is compatible. net6.0-ios was computed. net6.0-ios13.0 is compatible. net6.0-maccatalyst was computed. net6.0-maccatalyst14.0 is compatible. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net6.0-windows10.0.19041 is compatible. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Auth0.OidcClient.Core (>= 4.0.1)
- IdentityModel.OidcClient (>= 5.2.1)
-
net6.0-android29.0
- Auth0.OidcClient.Core (>= 4.0.1)
- IdentityModel.OidcClient (>= 5.2.1)
-
net6.0-ios13.0
- Auth0.OidcClient.Core (>= 4.0.1)
- IdentityModel.OidcClient (>= 5.2.1)
- System.Runtime.InteropServices.NFloat.Internal (>= 6.0.1)
-
net6.0-maccatalyst14.0
- Auth0.OidcClient.Core (>= 4.0.1)
- IdentityModel.OidcClient (>= 5.2.1)
- System.Runtime.InteropServices.NFloat.Internal (>= 6.0.1)
-
net6.0-windows10.0.19041
- Auth0.OidcClient.Core (>= 4.0.1)
- IdentityModel.OidcClient (>= 5.2.1)
- Microsoft.WindowsAppSDK (>= 1.2.221209.1)
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 | 23,393 | 4/29/2024 |
1.0.0 | 6,035 | 1/4/2024 |
1.0.0-beta.1 | 232 | 10/31/2023 |
1.0.0-beta.0 | 69 | 10/30/2023 |
Version 1.0.1
- Add net-6.0 target to Auth0 MAUI NuGet package.
- Bump Auth0.OidcClient.Core to v4, removing support for ClientSecret
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.