Azure Active Directory AcquireTokenAsync 不会触发事件

本文关键字:事件 Active Directory AcquireTokenAsync Azure | 更新日期: 2023-09-27 18:37:21

根据本教程 http://www.cloudidentity.com/blog/2014/08/28/use-adal-to-connect-your-universal-apps-to-azure-ad-or-adfs/我正在尝试将我的通用应用程序与Azure Active Directory连接。不幸的是,Windows Phone 8.1应用程序不能完全正常工作。

一切正常(当我单击两次按钮时,我可以成功登录,因为第二次他正在获得"静默"令牌和方法 AfterLogin 被执行),但是函数 AcquireTokenAsync 中的事件在我把我的凭据放在窗口中后没有被触发。

private async void Button_Click(object sender, RoutedEventArgs e)
{
    var result = await ac.AcquireTokenSilentAsync("https://graph.windows.net", ClientId);
    if (result != null && result.Status == AuthenticationStatus.Success)
        AfterLogin(result);
    else
        ac.AcquireTokenAndContinue("https://graph.windows.net", ClientId, WebAuthenticationBroker.GetCurrentApplicationCallbackUri(), AfterLogin);
}
public void AfterLogin(AuthenticationResult result)
{
    if (result.Status == AuthenticationStatus.Success)
        Frame.Navigate(typeof(HubPage));
}

ac 之后没有执行登录后有什么问题。AcquireTokenAndContinue() 结束它的工作?

Azure Active Directory AcquireTokenAsync 不会触发事件

您是否使用 Windows Phone 示例 https://github.com/AzureADSamples/NativeClient-WindowsPhone8.1 作为起点?在将示例集成到通用应用解决方案之前,该示例是否独立工作?我建议在 App.xaml.cs 代码中添加断点,以确保正确挂接继续事件。