使用第三方登录的问题 [英] problem in using third party login

查看:117
本文介绍了使用第三方登录的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面Mywebhome.aspx,其中我使用下面给定的来源按钮...



< asp:按钮ID =btnGoogleLoginrunat =serverCommandArgument =https://www.google.com/accounts/o8/idOnCommand =btnGoogleLogin_ClickText =使用Google登录OnClick =btnGoogleLogin_Click1/>





和Mywebhome.cs代码如下:



protected void Page_Load(object sender,EventArgs e)

{

OpenIdRelyingParty rp = new OpenIdRelyingParty();

var response = rp.GetResponse();

if(response!= null)

{

switch(response.Status)

{

case AuthenticationStatus.Authenticated:

Session [GoogleIdentifier] = response.ClaimedIdentifier.ToString();

Response.Redirect(Default.aspx);

break;

case AuthenticationStatus.Canceled:

Session [GoogleIdentifier] =取消。;

休息;

case AuthenticationStatus.Failed:

Session [GoogleIdentifier] =登录失败。;

休息;

}

}

}



protected void btnGoogleLogin_Click(object sender,CommandEventArgs e)

{

string discoveryUri = e.CommandArgument.ToString();

OpenIdRelyingParty openid = new OpenIdRelyingParty();

var URIbuilder = new UriBuilder(Request.Url){Query =};

var req = openid.CreateRequest(discoveryUri,URIbuilder.Uri ,URIbuilder.Uri);

req.RedirectToProvider();







}










和身份验证后我将其重定向到default.aspx页面...





代码工作正常,但 问题是..我将如何找到登录电子邮件ID 和用户名谷歌..





可以任何一个帮助请...



我使用的代码是从这篇文章中使用的..



http://dotnet.dzone.com/news/implementing-google-account\"

i have a page Mywebhome.aspx , in which i use the the given source below for button ...

<asp:Button ID="btnGoogleLogin" runat="server" CommandArgument="https://www.google.com/accounts/o8/id" OnCommand="btnGoogleLogin_Click" Text="Sign In with Google" OnClick="btnGoogleLogin_Click1"/>


and Mywebhome.cs code is as given below ..

protected void Page_Load(object sender, EventArgs e)
{
OpenIdRelyingParty rp = new OpenIdRelyingParty();
var response = rp.GetResponse();
if (response != null)
{
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
Session["GoogleIdentifier"] = response.ClaimedIdentifier.ToString();
Response.Redirect("Default.aspx");
break;
case AuthenticationStatus.Canceled:
Session["GoogleIdentifier"] = "Cancelled.";
break;
case AuthenticationStatus.Failed:
Session["GoogleIdentifier"] = "Login Failed.";
break;
}
}
}

protected void btnGoogleLogin_Click(object sender, CommandEventArgs e)
{
string discoveryUri = e.CommandArgument.ToString();
OpenIdRelyingParty openid = new OpenIdRelyingParty();
var URIbuilder = new UriBuilder(Request.Url) { Query = "" };
var req = openid.CreateRequest(discoveryUri, URIbuilder.Uri, URIbuilder.Uri);
req.RedirectToProvider();



}





and after authentication i redirect it to a default.aspx page ...


Code is working proprely , but problem is that .. how i will found login "email id" and "user name" of google ..


can any one help please ...

the code which is i use is using from this post ..

"http://dotnet.dzone.com/news/implementing-google-account"

推荐答案

这篇关于使用第三方登录的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆