Simple Registration HowToThe usage pattern exemplified below is almost identical to the usage of Attribute Exchange. Attribute Exchange can transfer any type of attributes. For more information see the OpenID Attribute Exchange 1.0 specification and OpenID Attribute Types. Relying Party sends a SRegRequestSRegRequest sregReq = SRegRequest.createFetchRequest();
sregReq.addAttribute("fullname", true);
sregReq.addAttribute("nickname", true);
sregReq.addAttribute("email", true);
AuthRequest req = _consumerManager.authenticate(discovered, return_to);
req.addExtension(sregReq);OpenID Provider receives a SRegRequestif (authReq.hasExtension(SRegMessage.OPENID_NS_SREG))
{
MessageExtension ext = authReq.getExtension(SRegMessage.OPENID_NS_SREG)
if (ext instanceof SRegRequest)
{
SRegRequest sregReq = (SRegRequest) ext;
List required = sregReq.getAttributes(true);
List optional = sregReq.getAttributes(false);
// prompt the user
}
}OpenID Provider sends a SRegResponse // data released by the user
Map userData = new HashMap();
//userData.put("email", "user@example.com");
SRegResponse sregResp = SRegResponse.createSRegResponse(sregReq, userData);
// (alternatively) manually add attribute values
sregResp.addAttribute("email", "user@example.com");
authSuccess.addExtension(sregResp);Relying Party receives a SRegResponseif (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG))
{
MessageExtension ext = authSuccess.getExtension(SRegMessage.OPENID_NS_SREG);
if (ext instanceof SRegResponse)
{
SRegResponse sregResp = (SRegResponse) ext;
String fullName = sregResp.getAttributeValue("fullname");
String nickName = sregResp.getAttributeValue("nickname");
String email = sregResp.getAttributeValues("email");
}
}
|
► Sign in to add a comment
String email = sregResp.getAttributeValues("email");
no such method in SRegResponse!
its String email = sregResp.getAttributeValue("email");
Did exactly as above, and sent it to google server. Google server returned only the usual openid params, but did not return any email attribute.
Does google require their own type uris? http://code.google.com/apis/accounts/docs/OpenID.html.
Or, is it because the openid I supplied was associated with google blogger and google blogger does not associate its openids with the email id used to log into blogger?
In which moment do i create de AuthSuccess? object ?
really badly documented
Last line of code: String email = sregResp.getAttributeValues("email"); should be: String email = sregResp.getAttributeValue("email");