Azure Active Directory Authentication in .NET MAUI
Sign-in is one of those features where the app code is short and the platform configuration is where things go wrong. This post covers both. Vladislav uses the Microsoft.Identity.Client package, defines a Constants class with the client ID and scopes, and includes commented lines for switching to an Azure AD B2C authority.
On Android, you add the BrowserTabActivity with an msal-prefixed scheme to AndroidManifest.xml and override OnActivityResult. On iOS, you add the URL types to Info.plist and override OpenUrl, which also allows the app to work with Microsoft Authenticator when MFA is enabled. An AuthService then wraps the login call and returns the claims, and the UI is just a button that calls it.
He notes that if the library doesn’t work on iOS or Mac Catalyst, .NET MAUI’s WebAuthenticator is an alternative. Links are provided to the sample app and to a MAUI Blazor version on GitHub.