OpenID: Trying to Get Email Address from Google OP

Ok figured it out. I posted a question on Goolge's Federated Log API group and was told to use Attribute exchange.

Below is the code for DotNetOpenAuth.

Please don't use this code in production. This is for illustration purposes only!

The Request:

using (OpenIdRelyingParty openid = new OpenIdRelyingParty())
{
    IAuthenticationRequest request = openid.CreateRequest(openidurl);

    var fetch = new FetchRequest();
    fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
    request.AddExtension(fetch);

    // Send your visitor to their Provider for authentication.
    request.RedirectToProvider();
}

The Response:

OpenIdRelyingParty openid = new OpenIdRelyingParty();
var response = openid.GetResponse();
if (response != null)
{
    switch (response.Status)
    {
        case AuthenticationStatus.Authenticated:
        {
            var fetch = response.GetExtension<FetchResponse>();
            string email = string.Empty();
            if (fetch != null)
            {
                email =  fetch.GetAttributeValue(
                    WellKnownAttributes.Contact.Email);
            }

            FormsAuthentication.RedirectFromLoginPage(
                response.ClaimedIdentifier, false);
            break;
        }
        ...
    }
}

When I try to get Full Name the response is null,please provide a solution to get the Full name, This post is really help ful Thank. My sample code like this.

var fetch = new FetchRequest();
            fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
            fetch.Attributes.AddRequired(WellKnownAttributes.Name.FullName);
            fetch.Attributes.AddRequired(WellKnownAttributes.Company.CompanyName);
            //fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);

            request.AddExtension(fetch);

And

if (fetch != null)
         {
             email = fetch.GetAttributeValue(WellKnownAttributes.Contact.Email);
             name = fetch.GetAttributeValue(WellKnownAttributes.Name.FullName);
             company = fetch.GetAttributeValue(WellKnownAttributes.Company.CompanyName);
         }