Thima.MauiAuth.Core 1.0.2

dotnet add package Thima.MauiAuth.Core --version 1.0.2
                    
NuGet\Install-Package Thima.MauiAuth.Core -Version 1.0.2
                    
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="Thima.MauiAuth.Core" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Thima.MauiAuth.Core" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Thima.MauiAuth.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Thima.MauiAuth.Core --version 1.0.2
                    
#r "nuget: Thima.MauiAuth.Core, 1.0.2"
                    
#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.
#:package Thima.MauiAuth.Core@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Thima.MauiAuth.Core&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Thima.MauiAuth.Core&version=1.0.2
                    
Install as a Cake Tool

MauiAuth

MauiAuth is a lightweight authentication-state framework for .NET MAUI inspired by Blazor's AuthenticationStateProvider.

Architecture

The recommended NuGet package is MauiAuth, which includes everything in one assembly:

  • platform-neutral state provider, events, token store contracts, options, and authorization helpers
  • JWT parsing and ClaimsPrincipal creation
  • token store implementations and secure-storage adapter contracts
  • DelegatingHandler for bearer token injection
  • dependency injection setup for app developers

The repository also keeps the smaller projects under src/ for development, but app developers should install the single MauiAuth package to avoid missing package references.

MauiAuth.Core targets net8.0 and does not reference MAUI.

Basic Usage

Install the dependency injection package:

dotnet add package MauiAuth
using MauiAuth.Core.Interfaces;
using MauiAuth.Extensions;

builder.Services.AddMauiAuth();
public sealed class LoginViewModel
{
    private readonly IAuthenticationStateProvider _auth;

    public LoginViewModel(IAuthenticationStateProvider auth)
    {
        _auth = auth;
        _auth.AuthenticationStateChanged += (_, args) =>
        {
            var isAuthenticated = args.CurrentState.IsAuthenticated;
        };
    }

    public Task SignInAsync(string jwt) => _auth.SignInAsync(jwt);

    public Task SignOutAsync() => _auth.SignOutAsync();
}
if (auth.IsAuthenticated)
{
    var user = auth.User;
}

MAUI SecureStorage Adapter

Bind MauiAuth.Storage to MAUI SecureStorage from your app project:

using MauiAuth.Extensions;
using MauiAuth.Storage.Services;
using Microsoft.Maui.Storage;

builder.Services
    .AddMauiAuth()
    .AddMauiAuthSecureStorage(_ => new DelegateSecureStorage(
        SecureStorage.Default.GetAsync,
        SecureStorage.Default.SetAsync,
        SecureStorage.Default.Remove));

HttpClient Integration

using MauiAuth.Http.Handlers;

builder.Services.AddHttpClient("api", client =>
{
    client.BaseAddress = new Uri("https://api.example.com");
})
.AddHttpMessageHandler<BearerTokenHandler>();

Session Restoration

Call session restore when the app starts:

var auth = services.GetRequiredService<IAuthenticationStateProvider>();
await auth.RestoreSessionAsync();

Sample App

See samples/MauiAuth.Sample for a runnable MAUI app that demonstrates:

  • dependency injection setup
  • MAUI SecureStorage token persistence
  • session restoration
  • sign in with a demo JWT
  • sign out
  • AuthenticationStateChanged UI updates
  • claims and role display

Build the Windows target:

dotnet build samples/MauiAuth.Sample/MauiAuth.Sample.csproj -f net9.0-windows10.0.19041.0

Packaging

The all-in-one src/MauiAuth/MauiAuth.csproj project is the recommended package to publish. Before publishing, add icon/readme metadata and sign packages if your organization requires it.

dotnet pack src/MauiAuth/MauiAuth.csproj -c Release
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.2 101 5/17/2026
1.0.0 111 5/17/2026 1.0.0 is deprecated because it has critical bugs.