Click here to Skip to main content
15,919,358 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

I want get information of the user from social network.
I have written a code for getting the information using OpenID.
But I am getting the message as Login Failed.
DotNetOpenAuth.OpenId.RelyingParty.FailedAuthenticationResponse


Code:
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.RelyingParty;
using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using System.Text;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        OpenIdRelyingParty rp = new OpenIdRelyingParty();
        var response = rp.GetResponse();
        var st = "";
        var msg = "";
        if (response != null)
        {
            switch (response.Status)
            {
                case AuthenticationStatus.Authenticated:
                    Session["GoogleIdentifier"] = response.ClaimedIdentifier.ToString();
                    st= response.ClaimedIdentifier.ToString();
                    msg = response.ToString();
                    Response.Redirect("Default.aspx");
                    break;
                case AuthenticationStatus.Canceled:
                    Session["GoogleIdentifier"] = "Cancelled.";
                    st = "Cancelled.";
                    msg = response.ToString();
                    break;
                case AuthenticationStatus.Failed:
                    Session["GoogleIdentifier"] = "Login Failed.";
                    st = "Login Failed.";
                    msg = response.ToString();
                    break;
            }
        }
        if (st!= "")
        {
            Label1.Text = st;
            Label2.Text = msg;
        }
    }
    //Onclick of Icon
    protected void btnGL_Click(object sender, CommandEventArgs e)
    {
        string GLUri = e.CommandArgument.ToString();
        OpenIdRelyingParty oid = new OpenIdRelyingParty();
        var Uribuilder = new UriBuilder(Request.Url) { Query = "" };
        var request = oid.CreateRequest(GLUri, Uribuilder.Uri, Uribuilder.Uri);
        request.RedirectToProvider();
    }   
}


Kindly suggest and give solution for the same.
Thanks.
Posted
Updated 27-Sep-12 20:41pm
v2

1 solution

Have a look at these sample examples on how to use social network login using OAuth:
Using Web APIs with OAuth 2.0[^]
C# Application Integration with Facebook & Twitter with oAuth[^]

Try and see if it helps!
 
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