我们有一个Xamarin.Forms应用程序,并尝试使用MSAL身份验证,并面临iOS项目的问题。它在模拟器中工作,但当由 Azure 管道构建并安装在真正的 iPhone 上时,会发生异常:
MSAL。Xamarin.iOS.4.14.0.MsalClient 异常: 错误代码: missing_entitlements Microsoft.Identity.Client.MsalClientException: 应用程序未在 因此,无法保存到 iOS 钥匙串。钥匙串访问组 "OURID.com.microsoft.adalcache"未在 Entitlements.plist...
OURID当然是实际价值的替代品。
以下是我们在 entitlements.plist 中的内容:
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
</array>
在 B2C 服务构造函数中:
var builder = PublicClientApplicationBuilder.Create(B2CConstants.ClientID)
.WithB2CAuthority(B2CConstants.AuthoritySignInSignUp)
.WithIosKeychainSecurityGroup(B2CConstants.IOSKeyChainGroup)
.WithRedirectUri($"msal{B2CConstants.ClientID}://auth");
我可能缺少导致异常的什么?
补充:如果我向管道添加变量替换任务,即使这样,这些任务也只能替换 xml 和 json 配置文件中的值,而不是 plist 文件。
我通过在文本编辑器中编辑项目并在
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
在属性组内
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
当我之前通过项目 GUI 执行此操作时,它仅影响属性组
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
这就是为什么它在模拟器中对我有用,但在真实设备上不起作用的原因。