0
Windows Phone 8.1 App (WINRT)을 작성 중입니다. 수행 방법 MVP/MVC를 사용하지 않고 Windows Phone 8.1 앱 **에서 GooglePlus 인증 (GooglePlus를 통한 로그인) **을 사용 하시겠습니까? Windows Phone 8.1의 GooglePlus 인증
나는 이벤트 탐색 이없는 윈도우 폰 8.0 앱하지만 윈도우 폰 8.1 웹보기 컨트롤에서 WebBrowser 컨트롤을 통해 웹 인증을 사용했다.아무도 도와 줄 수 있습니까?
씨 필립 Skakun에 따르면, 나는 썼다 :
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.ApplicationModel.Activation;
using Windows.Data.Json;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Security.Authentication.Web;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Web.Http;
namespace webbrokerFinal
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
Connect();
this.NavigationCacheMode = NavigationCacheMode.Required;
}
string FacebookClientIDString = "000000000000";
string FacebookCallbackUrlString = " https://www.facebook.com/connect/login_success.html";
private void Connect()
{
try
{
String FacebookURL = "https://www.facebook.com/dialog/oauth?client_id=" + FacebookClientIDString + "&redirect_uri=" + Uri.EscapeUriString(FacebookCallbackUrlString) + "&scope=read_stream&display=popup&response_type=token";
System.Uri StartUri = new Uri(FacebookURL);
System.Uri EndUri = new Uri(FacebookCallbackUrlString);
WebAuthenticationBroker.AuthenticateAndContinue(StartUri, EndUri, null, WebAuthenticationOptions.None);
}
catch (Exception Error) >> The remote procedure call failed. (Exception from HRESULT: 0x800706BE)
{
//
// Bad Parameter, SSL/TLS Errors and Network Unavailable errors are to be handled here.
//
}
}
public async void ContinueWebAuthentication(WebAuthenticationBrokerContinuationEventArgs args)
{
WebAuthenticationResult result = args.WebAuthenticationResult;
if (result.ResponseStatus == WebAuthenticationStatus.Success)
{
await GetFacebookUserNameAsync(result.ResponseData.ToString());
}
else if (result.ResponseStatus == WebAuthenticationStatus.ErrorHttp)
{
}
else
{
}
}
private async Task GetFacebookUserNameAsync(string webAuthResultResponseData)
{
//Get Access Token first
string responseData = webAuthResultResponseData.Substring(webAuthResultResponseData.IndexOf("access_token"));
String[] keyValPairs = responseData.Split('&');
string access_token = null;
string expires_in = null;
for (int i = 0; i < keyValPairs.Length; i++)
{
String[] splits = keyValPairs[i].Split('=');
switch (splits[0])
{
case "access_token":
access_token = splits[1]; //you may want to store access_token for further use. Look at Scenario5 (Account Management).
break;
case "expires_in":
expires_in = splits[1];
break;
}
}
//Request User info.
HttpClient httpClient = new HttpClient();
string response = await httpClient.GetStringAsync(new Uri("https://graph.facebook.com/me?access_token=" + access_token));
JsonObject value = JsonValue.Parse(response).GetObject();
string facebookUserName = value.GetNamedString("name");
}
}
}
그러나 나에게 오류를 제공합니다 : 원격 프로 시저 호출이 실패 . (HRESULT 예외 : 0x800706BE)
공유 한 링크에는 Facebook의 예가 있지만 linkedIn 인증 및 googlePlus 인증에서 나를 도울 수 있습니까? –
부여 오류 원격 프로 시저 호출에 실패했습니다. WebAuthenticationBroker.AuthenticateAndContinue (StartUri, EndUri, null, WebAuthenticationOptions.None) 실행시 HRESULT 예외 (0x800706BE에서 예외); –
구글, 트위터, 페이스 북, 플리커 샘플은 여기에 있습니다 : https://code.msdn.microsoft.com/windowsapps/Web-Authentication-d0485122 – kiewic