Get google account info using java's library gData

Showing 1-3 of 3 messages
Get google account info using java's library gData alx 3/30/12 1:41 AM
Hi,

Does anybody knows how to get user info(first name, last name, full name, email) from an google account using gData?
I must mention that I am able to perform the auth(I get the auth token from an android device - sent it to my server - auth using gData), but I don't know what Classes/calls to perform further in order to get the user info of the account.

Here is what I did:
ContactsService contactsService = new ContactsService("...");
contactsService.setUserToken(auth_token);   
ContactFeed feed = null;
try {  
  feed = contactsService.getFeed(new URL("https://www.google.com/m8/feeds/contacts/" + "some...@gmail.com" + "/full?max-results=10000"), ContactFeed.class);
}
catch (IOException e) {
  e.printStackTrace();
  return CONST.GOOGLE_AUTH_INVALID_TOKEN;
}
catch (ServiceException e) {
  e.printStackTrace();
  return CONST.GOOGLE_AUTH_INVALID_TOKEN;
}  
catch (NullPointerException e) {
  e.printStackTrace();
  return CONST.GOOGLE_AUTH_INVALID_TOKEN;
}

Thanks,
Alex.
Re: Get google account info using java's library gData Robin Green 3/30/12 1:54 AM
You don't need to use the Contacts API for this - you can just use the UserInfo service (which is better because then you are just asking the user for permission to access the information you need). However, if you use that, it doesn't matter whether you use gdata or the newer API, there is no Java API for the UserInfo service. You need to parse the info yourself, using the documentation at

https://developers.google.com/accounts/docs/OAuth2Login#userinfocall

Fortunately that's quite easy - just make a HTTP request and use Jackson to parse the returned JSON.
Re: Get google account info using java's library gData alx 3/30/12 1:59 AM
Thank you so much,

I'll just use the HTTP request and parse the JSON response.

Thanks again,
Alex.