After several attempts from multiple sources, the link below gives the closest guidance so far but not a working one for Android from my practical experience. https://www.syncfusion.com/blogs/post/authenticate-the-net-maui-app-with-azure-ad. Microsoft needs to provide a working sample.
Github copilot came in hand to provide both silent and interactive login options which work. See snippet below.
try
{
var accounts = await _pca.GetAccountsAsync();
var result = await _pca.AcquireTokenSilent(_scopes, accounts.FirstOrDefault())
.ExecuteAsync();
AuthResult = result;
return result;
}
catch (MsalUiRequiredException)
{
#if ANDROID
var activity = Microsoft.Maui.ApplicationModel.Platform.CurrentActivity;
var result = await _pca.AcquireTokenInteractive(_scopes)
.WithParentActivityOrWindow(activity)
.ExecuteAsync();
#elif WINDOWS
var windowHandle = ((MauiWinUIWindow)Microsoft.Maui.Controls.Application.Current.Windows[0].Handler.PlatformView).WindowHandle;
var result = await _pca.AcquireTokenInteractive(_scopes)
.WithParentActivityOrWindow(windowHandle)
.ExecuteAsync();
#else
var result = await _pca.AcquireTokenInteractive(_scopes)
.ExecuteAsync();
#endif
return result;
}