title: ADAL for Windows Phone 8.1 Problems
body: <p>I'm creating a Windows Phone 8.1 app (Windows Runtime) that will need to authenticate against an Azure Active Directory OAuth endpoint. I'm using the ADAL for WP81 nuget package as the authentication manager to get the OAuth token back. </p>
  
  <p>The problem I am struggling with, is where I need to call the various ADAL Login methods in the Phone page lifecycle. Right now I'm calling <code>AuthenticationContext.AquireTokenAndContine()</code> in the <code>Page.Loaded</code> event. I've also implemented the <code>ContinuationManager</code>, <code>IWebAuthenticationContinuable</code>, and <code>App.Activated</code> events as described in the github sample code. I'm also using <code>Windows.Security.Authentication.Web.WebAuthenticationBroker.GetCurrentApplicationCallbackUri()</code> to get my client URI.</p>
  
  <p>No matter what I do, I continue to get the following error. Any insight on what i can do? Thank you in advance for your help. </p>
  
  <blockquote>
    <p>'Microsoft.IdentityModel.Clients.ActiveDirectory.AdalException'
    occurred in mscorlib.ni.dll but was not handled in user code</p>
    
    <p>Additional information: authentication_ui_failed: The browser based
    authentication dialog failed to complete</p>
  </blockquote>
  
  <pre><code>async void MainPage_Loaded(object sender, RoutedEventArgs e)
  {
  
          await LoadFromViewModel();
  }
  
  public async Task LoadFromViewModel()
  {
   // Try to get a token without triggering any user prompt. 
   // ADAL will check whether the requested token is in the cache or can be obtained without user itneraction (e.g. via a refresh token).
      AuthenticationResult result = await authContext.AcquireTokenSilentAsync(this.viewModel.RESTApiResourceUri, this.viewModel.AzureADClientId);
      if (result != null &amp;&amp; result.Status == AuthenticationStatus.Success)
      {
        // A token was successfully retrieved. Get the To Do list for the current user  
        await viewModel.BindData();
      }
      else
      {
        // Acquiring a token without user interaction was not possible. 
        // Trigger an authentication experience and specify that once a token has been obtained the GetTodoList method should be called
  
       authContext.AcquireTokenAndContinue(this.viewModel.RESTApiResourceUri, this.viewModel.AzureADClientId, this.viewModel.AzureADRedirectUri, AuthenticationSuceeded);
           }
      }
  </code></pre>