簡體   English   中英

Windows Phone Silverlight 8.1中的異常Web身份驗證結果

[英]Exception web authentication result in windows phone silverlight 8.1

我想在我的Windows Phone應用中實現用Facebook登錄,當點擊登錄按鈕出現從Facebook彈出時,在這里輸入我的用戶名和密碼,都很好,當我想獲得令牌時,結果

WebAuthenticationResult myResult = await WebAuthenticationBroker.AuthenticateSilentlyAsync(startUri);

我得到這個例外:

用戶代碼未處理COMException

mscorlib.ni.dll中發生了類型為'System.Runtime.InteropServices.COMException'的異常,但未在用戶代碼中處理

附加信息:對COM組件的調用已返回錯誤HRESULT E_FAIL。

有解決該問題的解決方案嗎?

代替WebAuthenticationBroker.AuthenticateSilentlyAsync(startUri)使用WebAuthenticationBroker.AuthenticateAndContinue(requestUri, callbackUri)接下來在App.xaml中添加Application_ContractActivated事件。 您可以通過打開App.xaml並添加ContractActivated來做到這一點

<shell:PhoneApplicationService ContractActivated="Application_ContractActivated" />

這應該在App.xaml.cs中添加Application_ContractActivated方法。 在這種方法中,您可以得到如下結果:

public WebAuthenticationBrokerContinuationEventArgs WABContinuationArgs { get; set; }

        private void Application_ContractActivated(object sender, IActivatedEventArgs e)
                {
                    var _WABContinuationArgs = e as WebAuthenticationBrokerContinuationEventArgs;

                    if (_WABContinuationArgs != null)
                    {
                        WABContinuationArgs = _WABContinuationArgs;
                        var result = WABContinuationArgs.WebAuthenticationResult;
                    }
                }

請注意 ,此解決方案適用於Windows Phone Silverlight 8.1,而不適用於Windows Phone 8.1。 對於Windows Phone 8.1,這是相同的原理,但是您使用OnActivated方法而不是Application_ContractActivated。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM