问题描述:

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...

网友答案:

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.

网友答案:

Maybe you're not doing anything wrong - the provider may just not support the request, or chooses not to send the requested information.

http://blog.nerdbank.net/2008/07/how-to-use-dotnetopenid-attribute.html "As with all OpenID extensions, merely sending a request with an extension in it does not guarantee that the Provider will send a response to that extension back. The Provider may not support that extension, or may choose to not send any response. "

相关阅读:
Top