微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。