Xamarin 表单 ios - b2c 身份验证在模拟器中有效,但在设备中无效

问题描述

基于此示例 https://github.com/Azure-Samples/active-directory-b2c-xamarin-native.git

Android 可以运行,ios 模拟器也可以

但是在 iphone 设备中(在 2 中测试)我得到这个异常

应用程序没有在 Entitlements.plist 中启用钥匙串访问组。结果,无法保存到 iOS 钥匙串。 Entitlements.plist 中未启用钥匙串访问组“*******.com.microsoft.adalcache”。此外,使用 WithIosKeychainSecurityGroup api 设置钥匙串访问组。有关启用钥匙串访问组和权利的更多详细信息,请参阅 https://aka.ms/msal-net-enable-keychain-groups

相同的签名配置文件和证书

编辑:Entitlements.plist

<dict>
    <key>keychain-access-groups</key>
    <array>
    <string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
    </array>
</dict>

pcaBuilder:

 var builder = PublicclientApplicationBuilder.Create(B2CConstants.ClientID)
                .WithB2CAuthority(B2CConstants.AuthoritySignInSignUp)
                .WithIosKeychainSecurityGroup(B2CConstants.IOSKeyChainGroup)
                .WithRedirectUri($"msal{B2CConstants.ClientID}://auth");

常量:

public static string IOSKeyChainGroup = "com.microsoft.adalcache";

自定义权利:选定的 Entitlements.plist

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)