DinosaurTom
DinosaurTom

Reputation: 212

Azure Active Directory AcquireTokenAsync doesn't trigger event

Based on this tutorial http://www.cloudidentity.com/blog/2014/08/28/use-adal-to-connect-your-universal-apps-to-azure-ad-or-adfs/ I'm trying to connect my universal application with Azure Active Directory. Unfortunelly Windows Phone 8.1 app isn't working entirely right.

Everything wents okay (I can login sucessfully when I click twice button, because the second time he is getting "silent" token and method AfterLogin is perfomed) but the event in function AcquireTokenAsync isn't trigered after I put my credentials in window.

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));
}

What is wrong that the AfterLogin isn't perfomed after ac.AcquireTokenAndContinue() end it's work?

Upvotes: 1

Views: 2072

Answers (1)

vibronet
vibronet

Reputation: 7394

Did you use the Windows Phone sample https://github.com/AzureADSamples/NativeClient-WindowsPhone8.1 as starting point? Does the sample work on its own, before integrating it in the universal app solution? I would recommend adding breakpoints in the App.xaml.cs code to ensure that the continuation events are correctly hooked up.

Upvotes: 1

Related Questions