Simple Question for Generic Services

13 views
Skip to first unread message

Evan Ruff

unread,
Oct 24, 2011, 7:15:34 PM10/24/11
to gdata-ja...@googlegroups.com
Hey Guys,

I'm trying to get at the following service: https://www.googleapis.com/userinfo/email

I'm just looking to get the email of the user who is logged in. I've been able to get all my info successfully using the playground; however, I'm having a hell of a time getting to the service in my code. I've been using the follow code segment:

GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthConsumerKey( Credentials.CONSUMER_KEY );
oauthParameters.setOAuthConsumerSecret( Credentials.CONSUMER_SECRET );
oauthParameters.setOAuthToken( Credentials.oauthToken );
oauthParameters.setOAuthTokenSecret( Credentials.oauthSecret );

GoogleService googleService = new GoogleService( "userinfo", "myApp" );
googleService.setOAuthCredentials( oauthParameters, new OAuthHmacSha1Signer() );

URL serviceURL = new URL( "https://www.googleapis.com/userinfo/email" );
Feed emailResults = googleService.getFeed( serviceURL, Feed.class );
System.out.println( "Count: " + emailResults.getItemsPerPage() );

I'm getting a com.google.gdata.util.ParseException: Unrecognized content type:application/x-www-form-urlencoded;charset=UTF-8 when executing this, as the service does not appear to be in the format that the GoogleService class expects (atom). Is there an easier way to get this type of service information? I'm mainly concerned about reinventing the wheel around the OAuth Credentials and such. Is there any way to just get the RAW response?

Thanks for any tips!

E

 
Reply all
Reply to author
Forward
0 new messages