xamarin - 使用 AcquireTokenInteractive 时出现 MsalServiceException。AADSTS80014:验证请求在超过最大经过时间后响应
问题描述
我有一个 Xamarin Forms iOS 应用程序,它使用 MSAL (Microsoft.Identity.Client) 来获取访问令牌。
var app = PublicClientApplicationBuilder.Create(AppSettings.ClientId)
.WithTenantId(AppSettings.TenantId)
.WithIosKeychainSecurityGroup("com.microsoft.adalcache")
.WithRedirectUri($"msal{AppSettings.ClientId}://auth")
.Build();
var authResult = await this.app.AcquireTokenInteractive(scopes)
.WithParentActivityOrWindow(App.CurrentActivityOrWindow)
.ExecuteAsync();
此代码在 Android 上运行良好,但在 iOS 上,输入用户名和密码后,MsalUiRequiredException
会抛出 an 。我在我的 Microsoft Work 或 School 帐户上启用了两个因素,并且似乎在登录的第二部分之前引发了异常。
AADSTS80014: Validation request responded after maximum elapsed time exceeded.
异常详细信息似乎表明发生了超时,因此我尝试使用HttpClientFactory
增加超时的自定义,但仍然在同一位置抛出异常。
我的OpenUrl
覆盖AppDelegate
不会被调用。
public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
// Never get here
AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(url);
return base.OpenUrl(app, url, options);
}
我已经在我的Info.plist
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>{bundle Id}</string>
<key>CFBundleURLSchemes</key>
<array>
<string>msal{clientId}</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
</dict>
</array>
并启用钥匙串访问Entitlements.plist
<dict>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.microsoft.adalcache</string>
</array>
</dict>
我很确定 Azure 方面的配置正确,因为它在 Android 上运行。我需要在 iOS 上做其他事情吗?
解决方案
此答案不太可能适用于其他任何人,但问题是由于我们的 AD Sync 服务器脱机造成的。
现有的访问令牌正在工作,但我无法获得任何新的。
推荐阅读
- vulkan - 使用vulkan时记录命令的正确方法是什么?
- html - 在我的范围内扩展 Bootstrap Navigator 时遇到问题
- php - 私人频道上的 Laravel Echo + Pusher 订阅错误
- java - 使用 Jackson 在嵌套 JSON 对象中开始解析
- c++ - QGraphicsRectItem 移出场景
- outlook - Outlook 2016 不会在事件电子邮件邀请中呈现徽标(图像)
- laravel - Laravel 5.在视图“表单”中获取重定向变量到控制器
- twig - 选择树枝块处理顺序
- javascript - 从仪表板页面编辑器将 JavaScript 添加到 WordPress 页面
- matlab - 通过空间卷积找到 z 的偏导数