Hello,

I was able to successfully authenticate a domain user using openID and
collect and log access_token and token_secret for that particular
user. But I want to get his role, first name,last name,email. So I use
this code for that purpose.


private void commonMethod(HttpServletRequest req, HttpServletResponse
resp)
                        throws ServletException, IOException{

                GoogleOAuthParameters oauthParameters = new 
GoogleOAuthParameters();






        UserInfo user = (UserInfo)
req.getSession().getAttribute("user");

        oauthParameters = new GoogleOAuthParameters();
 
oauthParameters.setOAuthConsumerKey("*************.appspot.com");
        oauthParameters.setOAuthConsumerSecret("J-
x****************************20-Z");
 
oauthParameters.setOAuthToken((String)req.getSession().getAttribute("access_token"));
 
oauthParameters.setOAuthTokenSecret((String)req.getSession().getAttribute("oauth_token_secret"));


        resp.getWriter().print("authentication started");


        try {
                String feedUrlString = "https://apps-apis.google.com/a/
feeds/"+user.getEmail().split("@")[1]+"/user/2.0/";
                userservice = new UserService("marketplace-hello");


                // Initialize the variables needed to make the request
            URL feedUrl = new URL(feedUrlString);
            //System.out.println("Sending request to " +
feedUrl.toString());
            //System.out.println();
            GoogleService googleService =
                new GoogleService("user provisioning", "oauth-sample-
app");

            // Set the OAuth credentials which were obtained from the
step above.
            googleService.setOAuthCredentials(oauthParameters, new
OAuthHmacSha1Signer());

            // Make the request to Google
            UserFeed resultFeed = googleService.getFeed(feedUrl,
UserFeed.class);
            if(resultFeed instanceof
UserFeed)resp.getWriter().print("true");resp.getWriter().print("<br>");
            resp.getWriter().print("Response
Data:");resp.getWriter().print("<br>");
 
resp.getWriter().print("=====================================================");resp.getWriter().print("<br>");
            resp.getWriter().print("| TITLE: " +
resultFeed.getTitle().getPlainText());resp.getWriter().print("<br>");
            if (resultFeed.getEntries().size() == 0) {
                resp.getWriter().print("|\tNo entries
found.");resp.getWriter().print("<br>");
            } else {
              for (int i = 0; i < resultFeed.getEntries().size(); i++)
{
                UserEntry entry = (UserEntry)
resultFeed.getEntries().get(i);
                resp.getWriter().print("|\t" + (i + 1) + ": "
                    + entry.getTitle().getPlainText() + " &nbsp" +
entry.getEmail());resp.getWriter().print("<br>");
              }
            }
 
resp.getWriter().print("=====================================================");
            resp.getWriter().print("<br>");



                } catch (Exception e) {
                        resp.getWriter().print(e.toString());
                        resp.getWriter().print("Unable to authenticate user 
provisioning
service");
                }

        }


I get the titles but not emails. Here is a sample response.


authentication startedtrue
Response Data:
=====================================================
| TITLE: Users
|       1: user1  null
|       2: user2  null
=====================================================



Any help would be highly appreciated

-- 
You received this message because you are subscribed to the Google Groups 
"Google Apps Domain Information and Management APIs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-apps-mgmt-apis?hl=en.

Reply via email to