Using Azure AD B2C in Xamarin.iOS with simulator - Problem with keychain (the Team ID is null)

本秂侑毒 提交于 2021-02-07 18:36:29

问题


I'm developing a Xamarin.Forms app, and setting up Azure AD B2C for auth. I'm following the official tutorial. Everything works flawlessly for Andorid, but I'm facing an issue with th iOS project.

I've setup everything mentioned in the tutorial but that is not enough. In this post, it describes how you should configure the iOS Bundle Signing to reference as custom entitlement Entitlements.plist. Otherwise you get this error:

Microsoft.Identity.Client.MsalClientException: The application cannot access the iOS keychain for the application publisher (the TeamId is null). This is needed to enable Single Sign On between applications of the same publisher. This is an iOS configuration issue. See https://aka.ms/msal-net-enable-keychain-access for more details on enabling keychain access.

Well, if you do that using the Simulator, it doesn't work since apparently, you cannot set in iOS Bundle Signing configuration any custom Entitlement when using the simulator (commented here).

Does this mean that I cannot test Azure AD B2C in the iOS simulator?

Edit: It seems you cannot set the custom Entitlement if you don't have an Apple Developer Program signing identity. Does this mean that I cannot test Azure AD B2C in the iOS simulator without being enrolled in the Apple Development Program?

Thanks!


回答1:


You can use custom entitlements including keychain access groups in iOS Simulator. It's done the same way you set custom entitlements for a device build, it's just disabled for simulator by default. Steps:

  1. Modify your custom Entitlements.plist to include keychain access groups:

    <key>keychain-access-groups</key>
    <array>
         <string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
    </array>
    
  2. Apply the entitlements to the iOS Simulator configuration in project settings:

Once you have this in place, the MSAL library will be able to access that keychain group to store secrets in between app launches.



来源:https://stackoverflow.com/questions/64995697/using-azure-ad-b2c-in-xamarin-ios-with-simulator-problem-with-keychain-the-te

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!