Hello,
In want to retrieve user data to SignIn through Gmail or Yahoo id.
I am designing such a web application in which it has no own user registration.
User can use there existing Gmail or Yahoo 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 Yahoo and retrieve login information of user like username , firstname and lastname.
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:
break;
case AuthenticationStatus.Failed:
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.
With Warm Regards,
Deepak Pandey