Search code examples
azure-active-directorymauiazure-ad-b2cazure-ad-msal

MAUI authentication with MSAL for B2C shows black screen


I am working with the .NET MAUI starter project (calling it AuthTest) and adding the changes from this article, but when the android emulator tries to start the B2C process all I get back is black screen that just sits until the system gives me the 'AuthTest isn't responding' message. HAs anyone seen this and know what causes it?

The code works fine up to the AcquireTokenInteractive call and then just sits (presumably waiting for the B2C process to complete) with a black screen...no error message or any indication what it is looking for.

The code that stops at is:

public async Task<AuthenticationResult> LoginAsync(CancellationToken cancellationToken) {
            AuthenticationResult result;
            try {
                result = await _authClient
                .AcquireTokenInteractive(_constants.Scopes)
                .WithPrompt(Prompt.ForceLogin)
#if ANDROID
                .WithParentActivityOrWindow(Platform.CurrentActivity)
#endif
                .ExecuteAsync(cancellationToken);
                return result;
            }
            catch(MsalClientException) { return null; }
        }

It just never reaches the return result;

Has anyone seen this and have some suggestions to try?


Solution

  • For anyone trying the same thing as above, I have found that this article works. I have not yet compared this to the one above to find the differences, but the sample code from the linked article (in this answer) allows a MAUI application to login against AAD B2C tenant.