The MsalProvider is an IProvider implementation built on the official Microsoft Authentication Library (MSAL). It is NetStandard 2.0 so it works in both UWP and WPF apps.

Available in the CommunityToolkit.Authentication.Msal package.

using CommunityToolkit.Authentication;

string clientId = "YOUR-CLIENT-ID-HERE";
string[] scopes = new string[] { "User.Read" };

ProviderManager.Instance.GlobalProvider = new MsalProvider(clientId, scopes);

Prerequisite Configure Client Id in Partner Center


To obtain a Client Id, first register your app in Azure following the guidance here: Quickstart: Register an application with the Microsoft identity platform

After finishing the initial registration, you will also need to add an additional redirect URI. Click on "Authentication -> Add a Platform", select "Mobile and desktop applications", and check the "" checkbox on that page. Then click "Configure".


Parameter Type Default Description
clientId string Registered client id.
scopes string[] null Listof scopes to initially request.
redirectUri string Redirect URI for authentication response.
autoSignIn bool true Determines whether the provider attempts to silently log in upon instantiation.


Property Type Description
State ProviderState Gets the current authentication state of the provider.


Event Type Description
StateChanged EventHandler<ProviderStateChangedEventArgs> Event called when the provider state changes.


Method Arguments Returns Description
GetTokenAsync bool silentOnly = false, string[] scopes = null Task<string> Retrieve a token for the authenticated user.
AuthenticateRequestAsync HttpRequestMessage Task Authenticate an outgoing request.
SignInAsync Task Sign in a user.
SignOutAsync Task Sign out the current user.
TrySilentSignInAsync Task<bool> Try signing in silently, without prompts.