Hello Robert
Here is a working code for email settings with OAuth1.0.
GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthConsumerKey(CONSUMER_KEY);
oauthParameters.setOAuthConsumerSecret(CONSUMER_SECRET);
OAuthSigner signer = new OAuthHmacSha1Signer();
GoogleOAuthHelper oauthHelper = new GoogleOAuthHelper(signer);
oauthParameters.setScope(SCOPE);
oauthHelper.getUnauthorizedRequestToken(oauthParameters);
String requestUrl =
oauthHelper.createUserAuthorizationUrl(oauthParameters);
System.out.println(requestUrl);
System.out.println("Please visit the URL above to authorize your OAuth "
+ "request token. Once that is complete, press any key to "
+ "continue...");
System.in.read();
String token = oauthHelper.getAccessToken(oauthParameters);
System.out.println("OAuth Access Token: " + token + " " +
oauthParameters.getOAuthTokenSecret());
URL feedUrl = new
URL("https://apps-apis.google.com/a/feeds/emailsettings/2.0/example.com/username/delegation");
System.out.println("Sending request to " + feedUrl.toString());
System.out.println();
GoogleService googleService =
new GoogleService("apps", "oauth-sample-app");
// Set the OAuth credentials which were obtained from the step above.
googleService.setOAuthCredentials(oauthParameters, signer);
// Make the request to Google
BaseFeed resultFeed = googleService.getFeed(feedUrl, Feed.class);
System.out.println("Response Data:");
System.out.println("=====================================================");
System.out.println("| TITLE: " + resultFeed.getEntries().size());
if (resultFeed.getEntries().size() == 0) {
System.out.println("|\tNo entries found.");
} else {
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
BaseEntry entry = (BaseEntry) resultFeed.getEntries().get(i);
System.out.println("|\t" + (i + 1) + ": "
+ entry.getXmlBlob().getBlob());
}
}
System.out.println("=====================================================");
System.out.println();
We are still looking into why OAuth playground is not working with the same
tokens.
--
You received this message because you are subscribed to the Google Groups
"Google Apps Domain Information and Management APIs" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-apps-mgmt-apis/-/try0jQCzzLgJ.
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.