Search code examples
xamarin.formsxamarin.iosazure-ad-b2b

Xamarin Forms iOS app MsalClientException (the TeamId is null)


I'm working through the following example to add Azure B2C authentication to a Xamarin Forms app. I have the Android app working but the iOS app gets an exception in App.xaml.cs when the following code is called:

        AuthenticationClient = PublicClientApplicationBuilder.Create(Constants.ClientId)
            .WithIosKeychainSecurityGroup(Constants.IosKeychainSecurityGroups)
            .WithB2CAuthority(Constants.AuthoritySignin)
            .WithRedirectUri($"msal{Constants.ClientId}://auth")
            .Build();

The exception is:

Microsoft.Identity.Client.MsalClientException: The application cannot access the iOS keychain for the application publisher (the TeamId is null).

I reviewed the following link that is referenced in the exception:

https://aka.ms/msal-net-enable-keychain-access

I think I've addresses all the directions but still get the exception. Any suggestions? Where is the value for $(AppIdentifierPrefix) specified?

Using Xamarin.Forms 4.8.0.1560, Microsoft.Identity.Client 4.22.0, and Xcode 12.1


Solution

  • Did you missed this step: "Then open the project settings and in the iOS Bundle Signing select the Entitlements.plist inside the Custom Entitlements property."

    @LeoZhu-MSFT