应用程序无法访问Xamarin.Forms中的iOS密钥链,但可以在Android中使用
您好,我正在学习使用MSAL,但遇到了一个有线问题。我完全遵循了,我使用的是示例代码。但是在App.xaml.cs中构建客户端时,我仍然遇到此异常:应用程序无法访问Xamarin.Forms中的iOS密钥链,但可以在Android中使用,xamarin.forms,xamarin.ios,azure-active-directory,azure-ad-b2c,msal,Xamarin.forms,Xamarin.ios,Azure Active Directory,Azure Ad B2c,Msal,您好,我正在学习使用MSAL,但遇到了一个有线问题。我完全遵循了,我使用的是示例代码。但是在App.xaml.cs中构建客户端时,我仍然遇到此异常: // set to a unique value for your app, such as your bundle identifier. Used on iOS to share keychain access. static readonly string iosKeychainSecurityGroup = "c
// set to a unique value for your app, such as your bundle identifier. Used on iOS to share keychain access.
static readonly string iosKeychainSecurityGroup = "com.xamarin.adb2cauthorization";
microsoft.identity.client.MSALClient异常:应用程序无法
访问应用程序发布者的ios密钥链(团队id为
空)。这是在的应用程序之间启用单点登录所必需的
同一个出版商。这是一个ios配置问题。看见
有关
启用钥匙链访问
相关设置如下所示:
信息列表:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>ADB2C Auth</string>
<key>CFBundleURLSchemes</key>
<array>
<string>msal....</string>
</array>
<key>CFBundleTypeRole</key>
<string>None</string>
</dict>
<dict>
<key>CFBundleURLName</key>
<string>URL Type 1</string>
</dict>
</array>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.xamarin.adb2cauthorization</string>
</array>
</dict>
</plist>
public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(url);
return base.OpenUrl(app, url, options);
}
权利。plist:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>ADB2C Auth</string>
<key>CFBundleURLSchemes</key>
<array>
<string>msal....</string>
</array>
<key>CFBundleTypeRole</key>
<string>None</string>
</dict>
<dict>
<key>CFBundleURLName</key>
<string>URL Type 1</string>
</dict>
</array>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.xamarin.adb2cauthorization</string>
</array>
</dict>
</plist>
public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(url);
return base.OpenUrl(app, url, options);
}
我尝试将Microsoft.Identity.Client升级到v4.17.1,但仍然无法运行。由于共享代码适用于Android部分,我真的不确定我会错过什么。任何帮助都将不胜感激。转到ios项目属性=>ios捆绑签名并选择您的权利。plist authentications.plist文件应如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
</array>
</dict>
</plist>
aps环境
发展
密钥链访问组
$(AppIdentifierPrefix)com.microsoft.adalcache
转到ios项目属性=>ios捆绑包签名并选择您的权利。plist
authentications.plist文件应如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
</array>
</dict>
</plist>
aps环境
发展
密钥链访问组
$(AppIdentifierPrefix)com.microsoft.adalcache
请不要将代码或错误发布为“我的图像不好”。我更新了它。有一节特别提到“teamid为空”-谢谢我读了这篇文章。我想这和我的坏习惯一样。我错过了这一步:“然后打开项目设置,在iOS捆绑签名中选择Custom Authentications属性中的Authentications.plist。”也许你可以添加一个答案,这样我就可以接受它了。非常感谢。请不要将代码或错误发布为“我的图片不好”。我更新了它。有一节特别提到“teamid为空”-谢谢我读了这篇文章。我想这和我的坏习惯一样。我错过了这一步:“然后打开项目设置,在iOS捆绑签名中选择Custom Authentications属性中的Authentications.plist。”也许你可以添加一个答案,这样我就可以接受它了。非常感谢。