1

正如问题所说:)

这是我使用 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 作为提供者,但它只发送电子邮件。当我的页面重定向时,从提供商页面中,它仅显示电子邮件作为我在代码中需要的一件事,但我添加了名称和性别。

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

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

4

1 回答 1

0

google openid @ google opendid docs支持的请求参数

于 2013-01-26T06:39:17.343 回答