2014-09-30 54 views
3

我正嘗試使用WebAuthenticationBroker的AuthenticateAndContinue方法在Windows Phone 8.1中執行身份驗證。這是我執行身份驗證的頁面。AuthenticateAndContinue錯誤WP 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)中給出錯誤,並且響應爲空。在使用AuthenticateAsync方法的Windows 8.1應用程序中不會出現此問題。任何人都可以澄清如何解決這個問題?

回答

1
WebAuthenticationBroker.AuthenticateAndContinue(new Uri("https://manage.windowsazure.com/publishsettings/"), new Uri("https://manage.windowsazure.com/publishsettings/getpublishsettings"), null, WebAuthenticationOptions.None); 

試試這個