您好,我正在学习使用 MSAL,但遇到了有线问题。我完全遵循了教程,并且正在使用示例代码。但我在App.xaml.cs中构建客户端时仍然遇到此异常:
microsoft.identity.client.msalclientException:应用程序无法访问应用程序发布者的 ios 钥匙串(团队 ID 为空)。这是为了在同一发布者的应用程序之间启用单点登录所必需的。这是ios配置问题。有关启用钥匙串访问的更多详细信息,请参阅 https://aka.ms/msal-net-enable-keychain-access 。
AuthenticationClient = PublicClientApplicationBuilder.Create(Constants.ClientId)
.WithIosKeychainSecurityGroup(Constants.IosKeychainSecurityGroups)
.WithB2CAuthority(Constants.AuthoritySignin)
.WithRedirectUri($"msal{Constants.ClientId}://auth")
.Build();
Run Code Online (Sandbox Code Playgroud)
相关设置如下:
信息.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>
Run Code Online (Sandbox Code Playgroud)
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";
Run Code Online (Sandbox Code Playgroud)
权利.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC …Run Code Online (Sandbox Code Playgroud) xamarin.ios azure-active-directory xamarin.forms azure-ad-b2c azure-ad-msal