universal winphone authentication_ui_failed with ADAL

5

So this entire adal thing is a massive pain to get to work properly... Whenever I attempt to do a login using one of the identity providers (installed and provided by the azure AD backend through ADAL) windows phone throws a "authentication_ui_failed" exception.

I have been looking around and googling for a couple of days now but haven't been able to find anything useful. It probably doesn't help that I'm using a pre-release version of the ADAL...

In any case, this is what happens:

  1. click login (to start the process)
  2. windows phone halts the current application it appears (screen goes black and loads for a while)
  3. a new screen appears with the identity providers that were installed on the backend (facebook, google+, ...)
  4. click on facebook or google or whatever and it takes you to the relevant login page
  5. enter credentials and press login
  6. screen goes black again as device attempts to go back to application
  7. "resuming" shows on the screen for a split second
  8. exception is thrown

The exception is:

authentication_ui_failed: The browser based authentication dialog failed to complete.

inner exception:

System.IO.FileNotFoundException: The specified protocol is unknown. (Exception from HRESULT: 0x800C000D)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.WebUI.<AcquireAuthorizationAsync>d__0.MoveNext() 

and stacktrace:

at Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.WebUI.<AcquireAuthorizationAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.AcquireTokenInteractiveHandler.<AcquireAuthorizationAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.AcquireTokenInteractiveHandler.<PreTokenRequest>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase.<RunAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.<AcquireTokenCommonAsync>d__4e.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.<AcquireTokenAsync>d__47.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at ThreeAndMore.Mobile.Services.NetworkManager.<Login>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at ThreeAndMore.Mobile.Windows.MainPage.<Login>d__1.MoveNext()

And the code I'm using

        public async Task<AuthenticationResult> Login(IPlatformParameters parameters, bool isSignIn)
    {
        var authContext = new AuthenticationContext(AUTHORITY_URL, new TokenCache());

        if (CORRELATION_ID != null &&
                CORRELATION_ID.Trim().Length != 0)
        {
            authContext.CorrelationId = Guid.Parse(CORRELATION_ID);
        }

        String policy = "";
        if (isSignIn)
            policy = EMAIL_SIGNIN_POLICY;
        else
            policy = EMAIL_SIGNUP_POLICY;

        return await authContext.AcquireTokenAsync(SCOPES, ADDITIONAL_SCOPES, CLIENT_ID, new Uri(REDIRECT_URL), parameters, UserIdentifier.AnyUser, EXTRA_QP, policy);            
    }
}

which gets called like this:

        private async void Login()
    {
        try
        {
            NetworkManager mngr = NetworkManager.GetInstance();
            AuthenticationResult result = await mngr.Login(new PlatformParameters(PromptBehavior.Auto, false), true);
            MessageDialog msgbox = new MessageDialog("welcome " + result.UserInfo.Name + "User:" + result.UserInfo.DisplayableId);
            await msgbox.ShowAsync();

        }
        catch (Exception e)
        {
            MessageDialog msgbox = new MessageDialog(String.Format("LOGIN EXCEPTION: {0} with hresult: {1} and inner exception {2} and stacktrace: {3}", e.Message, e.HResult, e.InnerException, e.StackTrace));
            await msgbox.ShowAsync();
            System.Diagnostics.Debug.WriteLine(String.Format("LOGIN EXCEPTION: {0} with hresult: {1} and inner exception {2} and stacktrace: {3}", e.Message, e.HResult, e.InnerException, e.StackTrace));
        }

    }

One of the things that strikes me as odd is that it's a "FileNotFoundException" what file should it be able to find? It's a webrequest not a file-reading-request?

Even after searching for 2 days I haven't found a single promising solution. I don't know what else to do/try.

azure
win-universal-app
adal
asked on Stack Overflow Oct 23, 2015 by killernerd

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0