views:

56

answers:

1

i am using dotnetopenid for implementing openid in my page i am facing a problem with myopenid as i am getting a null ClaimsResponse what i am doing in page load

OpenIdRelyingParty openid = new OpenIdRelyingParty();

    //fetching response.
    var response = openid.GetResponse();

    //checking response from openid provider.
    if (response != null)
    {
        switch (response.Status)
        {
            case AuthenticationStatus.Authenticated:
                // This is where you would look for any OpenID extension responses included
                // in the authentication assertion.
                //var claimsResponse = response.GetExtension<ClaimsResponse>();

                ClaimsResponse claimsResponse = response.GetExtension(typeof(ClaimsResponse)) as ClaimsResponse;
                string firstName = string.Empty;
                string lastName = string.Empty;
                string nickName = string.Empty;
                string parsedName = string.Empty;

                if (claimsResponse != null)
                {
                    userName = claimsResponse.FullName;
                    emailId = claimsResponse.Email;
                    nickName = claimsResponse.Nickname;
                    int insertOpenID = 0;

and on click of login button

protected void btnLogin_Click(object sender, EventArgs e)
{
     //BEGIN : code added by Niraj for OpenId.

    //checks for page validation.
    if (!this.Page.IsValid)
    {
        return; // don't login if custom validation failed.           
    }

    //Adds extension to the request and redirects the request to provider.
    try
    {
        using (OpenIdRelyingParty openid = new OpenIdRelyingParty())
        {
            IAuthenticationRequest request = openid.CreateRequest(this.txtOpenId.Text);
            // This is where you would add any OpenID extensions you wanted
            // to include in the authentication request.
            var fields = new ClaimsRequest();
            fields.Email = DemandLevel.Require;
            fields.FullName = DemandLevel.Require;
            fields.Nickname = DemandLevel.Require;

            request.AddExtension(fields);

            //request.AddExtension(new ClaimsRequest
            //{
            //    Email = DemandLevel.Require,
            //    FullName = DemandLevel.Require

            //});
            // Send your visitor to their Provider for authentication.
            request.RedirectToProvider();
        }
    }
    catch (ProtocolException objException)
    {
        ErrorLog.InsertException(objException);
    }
    //End.

}
A: 

I have tha same problem, do you resolve that?

ozalvarez
Actually my problem was in storing the values in database in case when response is null i am unable to store any values so for solving this issue what iam doing is getting the response.FriendlyIdentifierForDisplay and using this value for parsing name and displaying that and also storing that value in database
Mac