Click here to Skip to main content
15,903,817 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900