我正在尝试使用WebAuthenticationBroker的AuthenticateAndContinue方法在Windows Phone 8.1中执行身份验证。这是我执行身份验证的页面。
public sealed partial class ScenarioFrame : Page,IWebAuthenticationContinuable
{
public static ScenarioFrame Current;
public ScenarioFrame()
{
this.InitializeComponent();
Current = this;
Load();
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached.
/// This parameter is typically used to configure the page.</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
Load();
}
private void Load()
{
WebAuthenticationBroker.AuthenticateAndContinue(new Uri("https://manage.windowsazure.com/publishsettings/"),new Uri("https://manage.windowsazure.com/publishsettings/getpublishsettings"));
Block.Visibility = Visibility.Visible;
}
public async void ContinueWebAuthentication(Windows.ApplicationModel.Activation.WebAuthenticationBrokerContinuationEventArgs args)
{
String resp = args.WebAuthenticationResult.ResponseData;
}
}
我使用了MSDN上提供的ContinuationManager和SuspensionManager来使用AndContinueMethod。当用户单击MainPage中的按钮时,应用程序将导航到ScenarioFrame页面。问题是回调后的WebAuthenticationResult在WebAuthenticationStatus属性(UserCancel)中出现错误,并且响应为null。在我使用AuthenticateAsync方法的Windows 8.1应用程序中不会出现此问题。任何人都可以澄清如何解决这个问题吗?
答案 0 :(得分:1)
WebAuthenticationBroker.AuthenticateAndContinue(new Uri("https://manage.windowsazure.com/publishsettings/"), new Uri("https://manage.windowsazure.com/publishsettings/getpublishsettings"), null, WebAuthenticationOptions.None);
试试这个