Windows Phone 的 ADAL 8.1 问题
ADAL for Windows Phone 8.1 Problems
我正在创建一个 Windows Phone 8.1 应用程序(Windows 运行时),它需要针对 Azure Active Directory OAuth 端点进行身份验证。我正在使用 ADAL for WP81 nuget 包作为身份验证管理器来取回 OAuth 令牌。
我遇到的问题是我需要在 Phone 页面生命周期中调用各种 ADAL 登录方法。现在我正在 Page.Loaded
事件中调用 AuthenticationContext.AquireTokenAndContine()
。我还实现了 ContinuationManager
、IWebAuthenticationContinuable
和 App.Activated
事件,如 github 示例代码中所述。我还使用 Windows.Security.Authentication.Web.WebAuthenticationBroker.GetCurrentApplicationCallbackUri()
获取我的客户端 URI。
无论我做什么,我都会继续收到以下错误。关于我能做什么的任何见解?预先感谢您的帮助。
'Microsoft.IdentityModel.Clients.ActiveDirectory.AdalException'
occurred in mscorlib.ni.dll but was not handled in user code
Additional information: authentication_ui_failed: The browser based
authentication dialog failed to complete
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 使用 WebAUthenticationBroker (WAB) 来显示其提示。 Windows Phone 8.1 中的 WAB 将在应用程序的整个 UX 加载后才会显示,因此您当前的方法位置将不起作用 - 至少在 WAB 行为不改变之前。请参阅 以了解类似主题。
我正在创建一个 Windows Phone 8.1 应用程序(Windows 运行时),它需要针对 Azure Active Directory OAuth 端点进行身份验证。我正在使用 ADAL for WP81 nuget 包作为身份验证管理器来取回 OAuth 令牌。
我遇到的问题是我需要在 Phone 页面生命周期中调用各种 ADAL 登录方法。现在我正在 Page.Loaded
事件中调用 AuthenticationContext.AquireTokenAndContine()
。我还实现了 ContinuationManager
、IWebAuthenticationContinuable
和 App.Activated
事件,如 github 示例代码中所述。我还使用 Windows.Security.Authentication.Web.WebAuthenticationBroker.GetCurrentApplicationCallbackUri()
获取我的客户端 URI。
无论我做什么,我都会继续收到以下错误。关于我能做什么的任何见解?预先感谢您的帮助。
'Microsoft.IdentityModel.Clients.ActiveDirectory.AdalException' occurred in mscorlib.ni.dll but was not handled in user code
Additional information: authentication_ui_failed: The browser based authentication dialog failed to complete
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 使用 WebAUthenticationBroker (WAB) 来显示其提示。 Windows Phone 8.1 中的 WAB 将在应用程序的整个 UX 加载后才会显示,因此您当前的方法位置将不起作用 - 至少在 WAB 行为不改变之前。请参阅