I am trying to access to google docs using OAuth2.0. I have got the client ID and secret key from Google API console. But When I am running this code, I am getting the exception. can you anyone suggest me if I am missing anything..
String CONSUMER_KEY = ".....apps.googleusercontent.com";
String CONSUMER_SECRET = "sM52Mts_d7snVIomnJaQkjkA";
GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthConsumerKey(CONSUMER_KEY);
oauthParameters.setOAuthConsumerSecret(CONSUMER_SECRET);
DocsService client = new DocsService("testing");
client.setOAuthCredentials(oauthParameters, new OAuthHmacSha1Signer());
// Retrieve user's list of Google Docs
String user = "[email protected]";
URL feedUrl = new URL("https://docs.google.com/feeds/default/private/full" +
"?xoauth_requestor_id=" + user);
DocumentListFeed resultFeed = client.getFeed(feedUrl, DocumentListFeed.class);
for (DocumentListEntry entry : resultFeed.getEntries()) {
System.out.println(entry.getTitle().getPlainText());
}
Exception:
com.google.gdata.util.AuthenticationException: Token invalid - Invalid token: Invalid user for the two legged OAuth
Token invalid - Invalid token: Invalid user for the two legged OAuth