Authentication_UI_failed exception while performing Authentication using Azure Active Directory

2

I am working on windows phone 8.1 application and want to Authenticate users accessing the back end web Api with Azure Active Directory Authentication. I have referred to Git Hub sample (https://github.com/Azure-Samples/active-directory-dotnet-windowsphone-8.1) , the sample works fine to me when the following code is written on a onclick event of a button

      AuthenticationResult result = await authContext.AcquireTokenSilentAsync(todoListResourceId, clientId);
         if (result != null && result.Status == AuthenticationStatus.Success)
         {
             // A token was successfully retrieved. Post the new To Do item
             AddTodo(result);
         }
         else
         {

             authContext.AcquireTokenAndContinue(todoListResourceId, clientId, redirectURI, AddTodo);
         }

However, when I write it in a async function and call that in the main page , it throws the below exception.

{Microsoft.IdentityModel.Clients.ActiveDirectory.AdalException: authentication_ui_failed: The browser based authentication dialog failed to complete ---> System.Exception: The remote procedure call failed. (Exception from HRESULT: 0x800706BE)
   at Windows.Security.Authentication.Web.WebAuthenticationBroker.AuthenticateAndContinue(Uri requestUri, Uri callbackUri, ValueSet continuationData, WebAuthenticationOptions options)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.WebUI.Authenticate(Uri authorizationUri, Uri redirectUri, IDictionary`2 headersMap, CallState callState)
   --- End of inner exception stack trace ---
   at Microsoft.IdentityModel.Clients.ActiveDirectory.WebUI.Authenticate(Uri authorizationUri, Uri redirectUri, IDictionary`2 headersMap, CallState callState)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenInteractiveHandler.AcquireAuthorization()
   at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.AcquireTokenAndContinueCommon(String resource, String clientId, Uri redirectUri, UserIdentifier userId, String extraQueryParameters, AuthenticationContextDelegate authDelegate)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.AcquireTokenAndContinue(String resource, String clientId, Uri redirectUri, AuthenticationContextDelegate authDelegate)
   at TodoListClient.MainPage.<MainPageAfterLoad>d__0.MoveNext()
    ErrorCode: authentication_ui_failed}``

I have also tried adding this code to the main_Loaded function which did not help .

c#
azure
authentication
active-directory
windows-phone-8.1
asked on Stack Overflow May 9, 2016 by Vyshnavi Reddy • edited May 9, 2016 by magicandre1981

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0