向OpenID提供者请求电子邮件地址 [英] Request email address from OpenID provider

查看:132
本文介绍了向OpenID提供者请求电子邮件地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实现OpenID,我想检索用户的电子邮件地址和有关该用户的其他信息,我正在这样做:

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);

但是提供程序不返回任何内容.我正在使用DotNetOpenID

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

我在做什么错了?

谢谢!

当我尝试使用MyOpenID或Google在 http://www.plaxo.com/上进行注册时,他们俩都说plaxo正在要求其他信息,但是当我测试我的网站时,他们什么也没说...

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

推荐答案

正如Martin所说,这取决于提供者.

As Martin said, it depends on the Provider.

MyOpenID不执行AttributeExchange.他们会进行sreg(简单注册),因此在您的请求中添加ClaimsRequest扩展名,您会从某些提供商那里获得ClaimsResponse退回.

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仅执行AttributeExchange,并且仅提供一个电子邮件地址.您的代码中唯一缺少的是,Google甚至不会自愿提供电子邮件地址,除非您在请求中将其标记为必填".在AttributeRequest构造函数中添加第二个参数"true",然后Google应该亮起并为您提供用户的电子邮件地址.

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.

以下是一些获取属性的文档和示例.

这篇关于向OpenID提供者请求电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆