SharedDeviceMode.Android.MSAL.Binding 1.0.1-net8.0

This is a prerelease version of SharedDeviceMode.Android.MSAL.Binding.
dotnet add package SharedDeviceMode.Android.MSAL.Binding --version 1.0.1-net8.0
                    
NuGet\Install-Package SharedDeviceMode.Android.MSAL.Binding -Version 1.0.1-net8.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="SharedDeviceMode.Android.MSAL.Binding" Version="1.0.1-net8.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharedDeviceMode.Android.MSAL.Binding" Version="1.0.1-net8.0" />
                    
Directory.Packages.props
<PackageReference Include="SharedDeviceMode.Android.MSAL.Binding" />
                    
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 SharedDeviceMode.Android.MSAL.Binding --version 1.0.1-net8.0
                    
#r "nuget: SharedDeviceMode.Android.MSAL.Binding, 1.0.1-net8.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.
#:package SharedDeviceMode.Android.MSAL.Binding@1.0.1-net8.0
                    
#: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=SharedDeviceMode.Android.MSAL.Binding&version=1.0.1-net8.0&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=SharedDeviceMode.Android.MSAL.Binding&version=1.0.1-net8.0&prerelease
                    
Install as a Cake Tool

SharedDeviceMode.Android.MSAL.Binding

Binding library for MSAL (Microsoft Authentication Library) Android Shared Device Mode (SDM) targeting .NET 8.0.

Description

This NuGet package provides a .NET binding for the MSAL Android SDK with Shared Device Mode support. It enables .NET MAUI and Xamarin.Android applications to use MSAL authentication features on Android devices configured for shared device scenarios.

Installation

Install the package via NuGet Package Manager:

dotnet add package SharedDeviceMode.Android.MSAL.Binding --version 1.0.0-net8.0

Or via Package Manager Console:

Install-Package SharedDeviceMode.Android.MSAL.Binding -Version 1.0.0-net8.0

Requirements

  • .NET 8.0 or later
  • Android API Level 24 (Android 7.0) or higher
  • Target Framework: net8.0-android34.0 or compatible

Features

  • ✅ Shared Device Mode detection
  • ✅ Silent and Interactive Sign In
  • ✅ Get current user
  • ✅ Check user activity status
  • ✅ Get access token
  • ✅ Sign Out
  • ✅ Async/await pattern support

Usage

Basic Setup

using MSAL.SDM.Android.Binding;
using Android.Content;

// Initialize the wrapper
var context = Android.App.Application.Context;
var msalWrapper = new MSALSDMWrapperAsync(context);

// Configure MSAL parameters
msalWrapper.Configure(
    clientId: "your-client-id",
    tenantId: "your-tenant-id",
    scope: "user.read",
    returnUri: "msauth://your.package.name/your-signature-hash"
);

Check Shared Device Mode

bool isSDM = msalWrapper.IsSharedDeviceMode();
if (isSDM)
{
    // Device is in Shared Device Mode
    // Use SDM-specific features
}

Get Current User

string? currentUser = msalWrapper.GetCurrentUser();

Silent Sign In

try
{
    var result = await msalWrapper.SignInSilentAsync();
    string accessToken = result.AccessToken;
    string username = result.Username;
}
catch (Exception ex)
{
    // Handle error or fall back to interactive sign in
}

Interactive Sign In

try
{
    var result = await msalWrapper.SignInInteractiveAsync();
    string accessToken = result.AccessToken;
    string username = result.Username;
}
catch (OperationCanceledException)
{
    // User cancelled the sign in
}
catch (Exception ex)
{
    // Handle error
}

Get Access Token

try
{
    string accessToken = await msalWrapper.GetAccessTokenAsync();
}
catch (Exception ex)
{
    // Handle error
}

Sign Out

try
{
    await msalWrapper.SignOutAsync();
}
catch (Exception ex)
{
    // Handle error
}

Dependencies

This package includes the following dependencies:

  • MSAL Android SDK 8.1.0
  • Microsoft Identity Common 23.1.0
  • Various AndroidX libraries
  • Kotlin libraries

.NET Version

This package targets .NET 8.0. The version suffix -net8.0 indicates the target framework.

When upgrading to .NET 9, look for packages with version suffix -net9.0.

Notes

  • This binding library is specifically designed for Android platforms
  • Shared Device Mode is only supported on Android devices
  • All async methods use Task-based async pattern
  • The library automatically handles callback-to-async conversion

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0-android34.0 is compatible.  net9.0-android was computed.  net10.0-android 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-net8.0 162 11/25/2025
1.0.0-net8.0 343 11/25/2025