通用winphone authentication_ui_failed with ADAL

时间:2015-10-23 09:19:06

标签: azure win-universal-app adal

所以这整个adal事情是一个巨大的痛苦才能正常工作...... 每当我尝试使用其中一个身份提供程序(通过ADAL安装并由azure AD后端提供)登录时,Windows Phone会抛出一个" authentication_ui_failed"异常。

我一直在环顾四周,谷歌搜索了几天,但没有找到任何有用的东西。我可能无法帮助我使用ADAL的预发布版本......

无论如何,这就是:

  1. 点击登录(开始流程)
  2. windows phone停止显示的当前应用程序(屏幕变黑并加载一段时间)
  3. 出现一个新屏幕,其中包含安装在后端的身份提供程序(Facebook,Google +,...)
  4. 点击Facebook或谷歌或其他任何内容,它会带您进入相关的登录页面
  5. 输入凭据并按登录
  6. 当设备尝试返回应用程序时,
  7. 屏幕再次变黑
  8. "恢复"在屏幕上显示一瞬间
  9. 抛出异常
  10. 例外是:

    authentication_ui_failed:基于浏览器的身份验证对话框无法完成。

    内部异常:

    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() 
    

    和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()
    

    我使用的代码

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

    这样被调用:

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

    令我感到奇怪的一件事是,它是一个&#34; FileNotFoundException&#34;应该找到什么文件?它是一个webrequest而不是文件读取请求?

    即使在搜索了2天后,我也找不到一个有希望的解决方案。我不知道还有什么可做/尝试。

0 个答案:

没有答案