openid(gmail 或 myopenid)仅返回电子邮件

发布于 2024-12-27 11:36:33 字数 2340 浏览 0 评论 0原文

正如问题所说:)

这是我使用 openid4java 发出的请求:

DiscoveryInformation discovered = manager.associate(discoveries);
System.out.println("discovered");
// store the discovery information in the user's session
session.setAttribute("openid-disco", discovered);

// obtain a AuthRequest message to be sent to the OpenID provider
AuthRequest authReq = manager.authenticate(discovered, returnToUrl);
System.out.println("authReq Ok");

// Attribute Exchange example: fetching the 'email' attribute
FetchRequest fetch = FetchRequest.createFetchRequest();
System.out.println("fetch");

fetch.addAttribute("gender",                           // attribute alias
                   "http://schema.openid.net/gender",  // type URI
                   true);  
fetch.addAttribute("email",
                   "http://schema.openid.net/contact/email",
                   true);
fetch.addAttribute("first",
                   "namePerson/first",
                   true);  
// attach the extension to the authentication request
authReq.addExtension(fetch);

这是我收到的响应。正如您所注意到的,名字和性别计数为 0:

openid.assoc_handle={HMAC-SHA256}{4f156b67}{jEurHw%3D%3D}&
openid.ax.count.email=1
&openid.ax.count.first=0
&openid.ax.count.gender=0
&openid.ax.mode=fetch_response&
openid.ax.type.email=http%3A%2F%2Fschema.openid.net%2Fcontact%2Femail&
openid.ax.type.first=namePerson%2Ffirst&
openid.ax.type.gender=http%3A%2F%2Fschema.openid.net%2Fgender
&openid.ax.value.email.1=saad.alothman%40gmail.com
&openid.claimed_id=http%3A%2F%2Fsaad-alothman.myopenid.com%2F
&openid.identity=http%3A%2F%2Fsaad-alothman.myopenid.com%2F
&openid.mode=id_res
&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0
&openid.ns.ax=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0
&openid.op_endpoint=http%3A%2F%2Fwww.myopenid.com%2Fserver&
openid.response_nonce=2012-01-17T14%3A32%3A26ZvN5JP4
&openid.return_to=https%3A%2F%2F192.168.133.17%3A10029%2Fwps%2FPA_openIdTest%2Fconsumer_returnurl.jsp
&openid.sig=8%2FES2uury7SxehrYVlH9gef9pB3l1eNQzCLqFJDTXDk%3D&

我尝试使用 myopenid 和 gmail 作为提供商,但它只发送电子邮件。当我的页面重定向时,从提供者页面中,它仅显示电子邮件作为我在代码中要求的一件事,但我添加了姓名和性别。

我想获取电子邮件以外的信息,例如姓名、性别和出生日期。

更新:我使用了 sreg 扩展对象,并且有三个值(姓名、电子邮件、昵称) 但是仍然希望能够获得其他值,例如地址......

As the question says :)

This is the request I made using openid4java:

DiscoveryInformation discovered = manager.associate(discoveries);
System.out.println("discovered");
// store the discovery information in the user's session
session.setAttribute("openid-disco", discovered);

// obtain a AuthRequest message to be sent to the OpenID provider
AuthRequest authReq = manager.authenticate(discovered, returnToUrl);
System.out.println("authReq Ok");

// Attribute Exchange example: fetching the 'email' attribute
FetchRequest fetch = FetchRequest.createFetchRequest();
System.out.println("fetch");

fetch.addAttribute("gender",                           // attribute alias
                   "http://schema.openid.net/gender",  // type URI
                   true);  
fetch.addAttribute("email",
                   "http://schema.openid.net/contact/email",
                   true);
fetch.addAttribute("first",
                   "namePerson/first",
                   true);  
// attach the extension to the authentication request
authReq.addExtension(fetch);

And this is the response I receive. As you notice, first name and gender count are 0:

openid.assoc_handle={HMAC-SHA256}{4f156b67}{jEurHw%3D%3D}&
openid.ax.count.email=1
&openid.ax.count.first=0
&openid.ax.count.gender=0
&openid.ax.mode=fetch_response&
openid.ax.type.email=http%3A%2F%2Fschema.openid.net%2Fcontact%2Femail&
openid.ax.type.first=namePerson%2Ffirst&
openid.ax.type.gender=http%3A%2F%2Fschema.openid.net%2Fgender
&openid.ax.value.email.1=saad.alothman%40gmail.com
&openid.claimed_id=http%3A%2F%2Fsaad-alothman.myopenid.com%2F
&openid.identity=http%3A%2F%2Fsaad-alothman.myopenid.com%2F
&openid.mode=id_res
&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0
&openid.ns.ax=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0
&openid.op_endpoint=http%3A%2F%2Fwww.myopenid.com%2Fserver&
openid.response_nonce=2012-01-17T14%3A32%3A26ZvN5JP4
&openid.return_to=https%3A%2F%2F192.168.133.17%3A10029%2Fwps%2FPA_openIdTest%2Fconsumer_returnurl.jsp
&openid.sig=8%2FES2uury7SxehrYVlH9gef9pB3l1eNQzCLqFJDTXDk%3D&

I tried myopenid and gmail as providers but it only sends the email. From the provider page when my page redirects, it shows only the email as the one thing that has been required by me in the code, but I have added the name and gender.

I would like to get info other than the email like name, gender, and DOB.

Upadte: i used sreg extension object and i have got three values (name,email,nickname)
however is still want to be able to get the other values like address ...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゃ人海孤独症 2025-01-03 11:36:33

google openid @ google opendid 文档 支持的请求参数

request parameters as supported by google openid @ google opendid docs

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文