从Gmail登录中检索用户数据 [英] Retrieve user data from gmail login

查看:99
本文介绍了从Gmail登录中检索用户数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hai,




通过gmail登录名检索用户数据.


我想通过Gmail ID检索用户数据以登录.
我正在设计这样的Web应用程序,其中没有自己的用户注册.
用户可以使用现有的Gmail ID在Web应用程序中登录.
对于这两个应用程序,我都需要OAuth使用方密钥和OAuth使用方秘密.
我想使用C#代码通过Gmail进行用户登录,并检索用户的登录信息,如用户名,名字和姓氏,密码,性别,邮政编码,Mobileno,城市.


我已使用此代码登录google
添加这些名称空间

使用DotNetOpenAuth.OpenId;
使用DotNetOpenAuth.OpenId.RelyingParty;


受保护的void Page_Load(对象发送者,EventArgs e)
{
如果(!IsPostBack)
{
OpenIdRelyingParty rp =新的OpenIdRelyingParty();
var r = rp.GetResponse();
如果(r!= null)
{
开关(r.Status)
{
case AuthenticationStatus.Authenticated:
Session ["GoogleIdentifier"] = r.ClaimedIdentifier.ToString();
休息;
case AuthenticationStatus.Canceled:
//lblAlertMsg.Text=已取消.";休息;
case AuthenticationStatus.Failed:
//lblAlertMsg.Text=登录失败.";休息;
}
}
}
}

受保护的void imgbtnGoogle_Click(对象发送者,ImageClickEventArgs e)
{
字符串DiscoveryUri ="https://www.google.com/accounts/o8/id";
OpenIdRelyingParty openid =新的OpenIdRelyingParty();
var b = new UriBuilder(Request.Url){查询="};
var req = openid.CreateRequest(discoveryUri,b.Uri,b.Uri);
req.RedirectToProvider();
}这段代码帮助我登录了Google.

但是现在的问题是如何检索用户的登录信息,如用户名,名字和姓氏,密码,性别,邮政编码,Mobileno,城市.

hai,




Retrieve user data from gmail login.


I want to retrieve user data to SignIn through Gmail id.
I am designing such a web application in which it has no own user registration.
User can use there existing Gmail id to SignIn in the web application.
I have required OAuth Consumer Key and OAuth Consumer Secret for both application.
I want C# code for user login through Gmail and retrieve login information of user like username , firstname and lastname,Password,Gender,Zipcode,Mobileno,City.


I have used this code for login with google
add these namespace

using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.RelyingParty;


protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
OpenIdRelyingParty rp = new OpenIdRelyingParty();
var r = rp.GetResponse();
if (r != null)
{
switch (r.Status)
{
case AuthenticationStatus.Authenticated:
Session["GoogleIdentifier"] = r.ClaimedIdentifier.ToString();
break;
case AuthenticationStatus.Canceled:
//lblAlertMsg.Text= "Cancelled."; break;
case AuthenticationStatus.Failed:
//lblAlertMsg.Text= "LoginFailed."; break;
}
}
}
}

protected void imgbtnGoogle_Click(object sender, ImageClickEventArgs e)
{
string discoveryUri = "https://www.google.com/accounts/o8/id";
OpenIdRelyingParty openid = new OpenIdRelyingParty();
var b = new UriBuilder(Request.Url) { Query = "" };
var req = openid.CreateRequest(discoveryUri, b.Uri, b.Uri);
req.RedirectToProvider();
}This code helped me in Login with the Google.

But Now the problem is how to retrieve login information of user like username , firstname and lastname,Password,Gender,Zipcode,Mobileno,City.

推荐答案

您好,jagadesh,
我不确定,但是我对此有所了解.
1)当用户在gmail帐户中注册时,它将以电子邮件ID作为唯一键的主键.
2)基于这一点,我们可以检索您想要的任何值.
3)见她了解更多详情
在ASP.NET中阅读Gmail收件箱邮件 [ ^ ]

4)我认为无法从gmail服务器获取信息.
Hi jagadesh,
I am not sure but i am giving an idea about this.
1)when ever user registered in gmail account,then it will take e-mail id as the primary key with unique.
2) basted on that we can retrive the values what ever you want.
3) see her for more details
Read Gmail Inbox Message in ASP.NET[^]

4)i think could not able to get the information from gmail server.


这篇关于从Gmail登录中检索用户数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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