c# - 在带有模拟器的 Xamarin.iOS 中使用 Azure AD B2C - 钥匙串(keychain)问题(团队 ID 为空)

标签 c# xamarin xamarin.forms xamarin.ios azure-ad-b2c

我正在开发一个 Xamarin.Forms 应用程序,并为身份验证设置 Azure AD B2C。我正在关注 official tutorial .
对于 Andorid,一切都完美无缺,但我正面临 iOS 项目的问题。
我已经设置了教程中提到的所有内容,但这还不够。在 this post ,它描述了您应该如何配置 iOS 捆绑签名 引用为自定义权利 权利.plist .否则你会得到这个错误:

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.


好吧,如果您使用模拟器执行此操作,它显然不起作用,因为在使用模拟器时,您不能在 iOS 捆绑签名配置中设置任何自定义权利(注释 here)。
这是否意味着我无法在 iOS 模拟器中测试 Azure AD B2C?
编辑 :如果您没有 Apple Developer Program 签名身份,您似乎无法设置自定义权利。这是否意味着我无法在没有注册 Apple 开发计划的情况下在 iOS 模拟器中测试 Azure AD B2C?
谢谢!

最佳答案

您可以在 iOS 模拟器中使用自定义权利,包括钥匙串(keychain)访问组。它的完成方式与您为设备build设置自定义权利的方式相同,默认情况下它只是对模拟器禁用。脚步:

  • 修改您的自定义Entitlements.plist包括钥匙串(keychain)访问组:
    <key>keychain-access-groups</key>
    <array>
         <string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
    </array>
    
  • 将权利应用于项目设置中的 iOS 模拟器配置:

  • enter image description here
    完成此操作后,MSAL 库将能够访问该钥匙串(keychain)组以在应用程序启动之间存储 secret 。

    关于c# - 在带有模拟器的 Xamarin.iOS 中使用 Azure AD B2C - 钥匙串(keychain)问题(团队 ID 为空),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64995697/

    相关文章:

    c# - MouseEnter 事件的奇怪行为

    c# - ProtoBuff.Net 不支持 null。为什么?

    c# - 设置 ninject 比较规则 I +"Somevalue"= Somevalue

    c# - .NET 中的代理身份验证 - 用于外部 API

    Xamarin.Forms 图像未显示

    push-notification - 用于聊天等实时应用程序的 Signal R 与推送通知

    c# - 如何在 MvvmCross 4.0 中将 fragment 添加到后台?

    c# - 禁止在 ListView 中选择项目

    c# - 如何使用 Xamarin Forms Shell 在 iOS 中的 Tabbar 行和图标之间添加空格?

    android - Xamarin.Android、AndroidManifest.xml、AndroidManifestMerger、xmlns :tools schema, 始终手动替换