// obtain a AuthRequest message to be sent to the OpenID provider
AuthRequest authReq = manager.authenticate(discovered, returnToUrl);
// Attribute Exchange example: fetching the 'email' attribute
FetchRequest fetch = FetchRequest.createFetchRequest();
// Using axschema
fetch.addAttribute("emailax", "http://axschema.org/contact/email",
true);
fetch.addAttribute("firstnameax",
"http://axschema.org/namePerson/first", true);
fetch.addAttribute("lastnameax",
"http://axschema.org/namePerson/last", true);
fetch.addAttribute("fullnameax", "http://axschema.org/namePerson",
true);
fetch.addAttribute("email",
"http://schema.openid.net/contact/email", true);
// Using schema.openid.net (for compatibility)
fetch.addAttribute("firstname",
"http://schema.openid.net/namePerson/first", true);
fetch.addAttribute("lastname",
"http://schema.openid.net/namePerson/last", true);
fetch.addAttribute("fullname",
"http://schema.openid.net/namePerson", true);
// attach the extension to the authentication request
authReq.addExtension(fetch);