Request email address from OpenID provider

只愿长相守 提交于 2020-01-03 10:47:10

问题


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


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/594548/request-email-address-from-openid-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!