Hi, i am working with gmail authentication in application using asp.net, Here in button click event i am getting error. so,please anyone having idea about the error please let me know....
Here is my code:
aspx page:
<asp:Button ID="btnGmail" runat="server" Text="Sign In With Google" OnCommand="btnGmail_Click">
.cs page
protected void Page_Load(object sender, EventArgs e)
{
HandleOpenIDProviderResponse();
}
protected void HandleOpenIDProviderResponse()
{
var response = openid.GetResponse();
if (response != null)
{
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
//NotLoggedIn.Visible = false;
//btngmaillogout.Visible = true;
var fetchResponse = response.GetExtension<FetchResponse>();
Session["FetchResponse"] = fetchResponse;
var response2 = Session["FetchResponse"] as FetchResponse;
lblemail.Text = response2.GetAttributeValue(WellKnownAttributes.Contact.Email);
lblname.Text = GetFullname(response2.GetAttributeValue(WellKnownAttributes.Name.First), response2.GetAttributeValue(WellKnownAttributes.Name.Last));
lblbirthdate.Text = response2.GetAttributeValue(WellKnownAttributes.BirthDate.WholeBirthDate);
lblphone.Text = response2.GetAttributeValue(WellKnownAttributes.Contact.Phone.Mobile);
lblgender.Text = response2.GetAttributeValue(WellKnownAttributes.Person.Gender);
Session["Email"] = lblemail.Text;
Session["UserName"] = lblname.Text;
value = Session["UserName"].ToString();
break;
}
}
else
{
return;
}
}
protected void btnGmail_Click(object sender, CommandEventArgs e)
{
string discoveryUri = e.CommandArgument.ToString();
var b = new UriBuilder("https://www.facebook.com/") { Query = "" };
var req = openid.CreateRequest(discoveryUri, b.Uri, b.Uri);
var fetchRequest = new FetchRequest();
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Name.First);
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Name.Last);
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Person.Gender);
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Phone.Mobile);
fetchRequest.Attributes.AddRequired(WellKnownAttributes.BirthDate.WholeBirthDate);
req.AddExtension(fetchRequest);
req.RedirectToProvider();
}
private static string GetFullname(string first, string last)
{
var _first = first ?? "";
var _last = last ?? "";
if (string.IsNullOrEmpty(_first) || string.IsNullOrEmpty(_last))
return "";
return _first + " " + _last;
}
Getting error in btnGmail_Click Event,
var req = openid.CreateRequest(discoveryUri, b.Uri, b.Uri); //in this line getting error