访问控制服务(ACS)Google

在开发Windows Store App 应用中 我们有可能用到Google,Facebook,Windows Live Account……等方式登录,

那么我们该如何做呢:

Google:

string callbackURL = "urn:ietf:wg:oauth:2.0:ooa";  // you can get this urn from google ....
String GoogleURL = "https://accounts.google.com/o/oauth2/auth?client_id=" + Uri.EscapeDataString("866863649802.apps.googleusercontent.com") + "&redirect_uri=" + Uri.EscapeDataString(callbackURL) + "&response_type=code&scope=" + Uri.EscapeDataString("http://picasaweb.google.com/data");

System.Uri StartUri = new Uri(GoogleURL);
// When using the desktop flow, the success code is displayed in the html title of this end uri
System.Uri EndUri = new Uri("https://accounts.google.com/o/oauth2/approval?");

WebAuthenticationResult WebAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(
WebAuthenticationOptions.UseTitle,
StartUri,
EndUri);
if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
{
this.tbToken.Text = WebAuthenticationResult.ResponseData.ToString();
}
else if (WebAuthenticationResult.ResponseStatus == WebAuthenticationStatus.ErrorHttp)
{
this.tbToken.Text = "HTTP Error returned by AuthenticateAsync() : " + WebAuthenticationResult.ResponseErrorDetail.ToString();
}
else
{
this.tbToken.Text = "Error returned by AuthenticateAsync() : " + WebAuthenticationResult.ResponseStatus.ToString();
}

posted @ 2013-05-08 18:28  Angkor--:--  阅读(114)  评论(0)    收藏  举报