gpt4 book ai didi

c# - 适用于 Windows Phone 8.1 的 ADAL 问题

转载 作者:行者123 更新时间:2023-12-03 03:15:21 26 4
gpt4 key购买 nike

我正在创建一个 Windows Phone 8.1 应用程序(Windows 运行时),该应用程序需要针对 Azure Active Directory OAuth 终结点进行身份验证。我使用 ADAL for WP81 nuget 包作为身份验证管理器来获取 OAuth token 。

我遇到的问题是我需要在电话页面生命周期中调用各种 ADAL 登录方法。现在,我在 Page.Loaded 事件中调用 AuthenticationContext.AquireTokenAndContine() 。我还实现了 ContinuationManagerIWebAuthenticationContinuableApp.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) 来显示其提示。在加载应用程序的整个 UX 之前,Windows Phone 8.1 中的 WAB 不会显示,因此您当前的方法位置将不起作用 - 至少在 WAB 行为不改变之前。请参阅Authentication failed with Azure Active Directory in Windows Phone对于类似的线程。

关于c# - 适用于 Windows Phone 8.1 的 ADAL 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28376842/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com