C# Azure Active Directory AcquireTokenAsync不';t触发事件

C# Azure Active Directory AcquireTokenAsync不';t触发事件,c#,win-universal-app,azure-active-directory,C#,Win Universal App,Azure Active Directory,基于本教程,我正在尝试将我的通用应用程序与Azure Active Directory连接。不幸的是,Windows Phone 8.1应用程序不能完全正常工作 一切正常(当我点击两次按钮时,我可以成功登录,因为他第二次获得“静默”令牌,登录后方法被执行),但函数AcquireTokenAsync中的事件在我将凭据放入窗口后不会触发 private async void Button_Click(object sender, RoutedEventArgs e) { var result

基于本教程,我正在尝试将我的通用应用程序与Azure Active Directory连接。不幸的是,Windows Phone 8.1应用程序不能完全正常工作

一切正常(当我点击两次按钮时,我可以成功登录,因为他第二次获得“静默”令牌,登录后方法被执行),但函数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()结束工作后未执行AfterLogin有什么错?

您是否使用Windows Phone示例作为起点?在将其集成到universal app解决方案中之前,该示例是否独立工作?我建议在App.xaml.cs代码中添加断点,以确保继续事件正确连接。

我使用此示例,我没有一个WP8.1解决方案,而是从启动Universal App开始。我确保app.xaml.cs中的事件和继续事件正确连接。问题已解决。这说明我不应该创建adal库的很多对象。关键是在App.xaml.cs中创建所有内容,然后只将其传递到登录页面、主页等。