gpt4 book ai didi

xamarin.forms - 该应用程序无法访问 Xamarin.Forms 中的 iOS 钥匙串(keychain),但可在 Android 中使用

转载 作者:行者123 更新时间:2023-12-04 17:26:09 25 4
gpt4 key购买 nike

您好,我正在学习使用 MSAL,但遇到了一个有线问题。我完全跟着tutorial ,我正在使用示例代码。但是我仍然在 中构建客户端时遇到了这个异常App.xaml.cs :

microsoft.identity.client.msalclientexception: the application cannotaccess the ios keychain for the application publisher (the team id isnull). this is needed to enable single sign on between applications ofthe same publisher. this is an ios configuration issue. seehttps://aka.ms/msal-net-enable-keychain-access for more details onenabling keychain access.

AuthenticationClient = PublicClientApplicationBuilder.Create(Constants.ClientId)
.WithIosKeychainSecurityGroup(Constants.IosKeychainSecurityGroups)
.WithB2CAuthority(Constants.AuthoritySignin)
.WithRedirectUri($"msal{Constants.ClientId}://auth")
.Build();
相关设置如下:
info.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>
Contants.cs 中的 ioskeychain :
 // 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";

权利.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>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.xamarin.adb2cauthorization</string>
</array>
</dict>
</plist>

AppDelegate:
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 Bundle Signing 并选择您的 Entitlements.plist。
Entitlements.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>

关于xamarin.forms - 该应用程序无法访问 Xamarin.Forms 中的 iOS 钥匙串(keychain),但可在 Android 中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63272380/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com