views:

140

answers:

2

I've been using DoNetOpenAuth library and followed the example here

The authentication is working, but even though I require an email, the claimsresponse is null. In fact, it doesn't matter what I require, claimsresponse is always null. Not sure what I'm doing wrong and I'd appreciate your help.

Thanks in advance.

Here is my login button code

protected void btnSubmit_Click( object sender, EventArgs e )
    {
        //Login button has been pushed. Add an extension and redirect
        using (OpenIdRelyingParty openId = new OpenIdRelyingParty())
        {
            IAuthenticationRequest request = openId.CreateRequest( txtOpenID.Text );

            request.AddExtension( new ClaimsRequest
                                    {
                                        Email = DemandLevel.Require,
                                        Country = DemandLevel.Request,
                                        TimeZone = DemandLevel.Request
                                    } );

            request.RedirectToProvider();

        }
    }

Here is the page load code. ClaimsResponse variable is always null though.

protected void Page_Load( object sender, EventArgs e )
    {
        OpenIdRelyingParty openId = new OpenIdRelyingParty();
        var response = openId.GetResponse();

        //check if we're processing a request
        if(response != null)
        {
            switch ( response.Status )
            {
                case AuthenticationStatus.Authenticated:

                    //authentication worked. grab our required fields
                    var claimsResponse = response.GetExtension<ClaimsResponse>();

                    //TODO enter required fields into the database

                    break;
                case AuthenticationStatus.Canceled:
                    //TODO handle cancel
                    break;

                case AuthenticationStatus.Failed:
                    //TODO handle failed
                    break;
            }
        }
    }
A: 

Turns out that Google does not send back any information you request. They will authenticate but that's about it. Hope this helps anyone else with this problem.

Matt
A: 

Scott Hanselman has a recent podcast on DoNetOpenAuth. On the podcast, Scott Arnott, author of DotNetOpenAuth, claims that Google's OAuth implementation doesn't properly conform to the specs and says it should fail rather than return null.

Mike Scott