简体   繁体   English

Windows Phone 8.1的ADAL问题

[英]ADAL for Windows Phone 8.1 Problems

I'm creating a Windows Phone 8.1 app (Windows Runtime) that will need to authenticate against an Azure Active Directory OAuth endpoint. 我正在创建一个Windows Phone 8.1应用程序(Windows运行时),该应用程序需要针对Azure Active Directory OAuth终结点进行身份验证。 I'm using the ADAL for WP81 nuget package as the authentication manager to get the OAuth token back. 我使用WP81 nuget包的ADAL作为身份验证管理器,以获取OAuth令牌。

The problem I am struggling with, is where I need to call the various ADAL Login methods in the Phone page lifecycle. 我苦苦挣扎的问题是,我需要在“电话”页面生命周期中调用各种ADAL登录方法。 Right now I'm calling AuthenticationContext.AquireTokenAndContine() in the Page.Loaded event. 现在,我在Page.Loaded事件中调用AuthenticationContext.AquireTokenAndContine() I've also implemented the ContinuationManager , IWebAuthenticationContinuable , and App.Activated events as described in the github sample code. 我还实现了ContinuationManagerIWebAuthenticationContinuableApp.Activated事件,如github示例代码中所述。 I'm also using Windows.Security.Authentication.Web.WebAuthenticationBroker.GetCurrentApplicationCallbackUri() to get my client URI. 我还使用Windows.Security.Authentication.Web.WebAuthenticationBroker.GetCurrentApplicationCallbackUri()获取我的客户端URI。

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. 预先感谢您的帮助。

'Microsoft.IdentityModel.Clients.ActiveDirectory.AdalException' occurred in mscorlib.ni.dll but was not handled in user code mscorlib.ni.dll中发生“ Microsoft.IdentityModel.Clients.ActiveDirectory.AdalException”,但未在用户代码中处理

Additional information: authentication_ui_failed: The browser based authentication dialog failed to complete 附加信息:authentication_ui_failed:基于浏览器的身份验证对话框无法完成

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

ADAL uses the WebAUthenticationBroker (WAB) for displaying its prompts. ADAL使用WebAUthenticationBroker(WAB)来显示其提示。 The WAB in Windows Phone 8.1 will not show up until the entire UX of the app has been loaded, hence your current method location won't work - at least until the WAB behavior doesn't change. Windows Phone 8.1中的WAB在应用程序的整个UX加载完毕后才会显示,因此您的当前方法位置将不起作用-至少直到WAB行为不变为止。 Please see Authentication failed with Azure Active Directory in Windows Phone for a similar thread. 请参阅Windows Phone中的Azure Active Directory身份验证失败以获取类似线程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM