Request email address from OpenID provider

dotnetopenauthopenid

I'm implementing OpenID and I would like to retrieve the user's email address and other information about the user, I'm doing this:

var fetch = new FetchRequest();
fetch.AddAttribute(new AttributeRequest(WellKnownAttributes.Contact.Email));
request.AddExtension(fetch);

But the provider doesn't return anything. I'm using DotNetOpenID

What am I doing wrong?

thanks!

EDIT:

When I try to signup at http://www.plaxo.com/ using MyOpenID or Google, they both say plaxo is requesting additional information, but when I test my site they doesn't say anything…

Best Answer

As Martin said, it depends on the Provider.

MyOpenID doesn't do AttributeExchange, I think. They do sreg (Simple Registration) though, so add a ClaimsRequest extension to your request and you'll get a ClaimsResponse back from some Providers.

Google only does AttributeExchange, and only provides an email address. The only thing you're missing from your code is that Google also doesn't even volunteer the email address unless you mark it as "Required" in your request. Add a ", true" second parameter to the AttributeRequest constructor and then Google should light up and give you the users' email address.

Here are some docs and samples of getting attributes.