I'm trying to write a new java webapp and want it to display a user's
activities. I'd like to have this work with orkut to start out, but
hopefully would like to integrate with other opensocial containers
such as linkedin, myspace, etc... I'm currently using the opensocial
java client in my development.
Right now I'm struggling trying to understand how to redirect the user
to orkut from my webapp so he can login if necessary add the
application to their profile, and then redirect this person back to my
webapp so that I can fetch the activities in the background and
display it on my app.
I've noticied that the OpenSocialProvider.ORKUT is defined as:
ORKUT(null, null, null, "
http://www.orkut.com/social/rest/",
"
http://www.orkut.com/social/rpc/", "
orkut.com",
BodySigningMethod.SIGN_BODY_HASH, true),
so there are no urls for requesting a token, authenticating url and
getting the access token. So I started using the
OpenSocialProvider.GOOGLE (since it has actual values for those urls
defined) in my code as follows.
OpenSocialProvider provider = OpenSocialProvider.GOOGLE;
final OpenSocialClient client = new OpenSocialClient
(provider);
client.setProperty(OpenSocialClient.Property.CONSUMER_SECRET,
CONSUMER_SECRET);
client.setProperty(OpenSocialClient.Property.CONSUMER_KEY,
"
igoogle.com:1212121212121212");
OpenSocialLoginInfo loginInfo = new OpenSocialLoginInfo();
session.setAttribute(OPEN_SOCIAL_CLIENT, client);
try {
Token token = OpenSocialOAuthClient.getRequestToken
(client, provider);
session.setAttribute("token_secret", token.secret);
String loginUrl = OpenSocialOAuthClient.getAuthorizationUrl
(provider, token, callbackUrl);
....
} catch (Exception e) {
e.printStackTrace();
}
However, I always get the following exception:
Exception in thread "main" java.io.IOException: Container returned
status 400 "Server returned HTTP response code: 400 for URL:
https://www.google.com/accounts/OAuthGetRequestToken?scope=http%3A%2F%2Fsandbox.gmodules.com%2Fapi%2Fpeople&oauth_consumer_key=igoogle.com%3A12121212121212&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1257411304&oauth_nonce=14494432821489&oauth_version=1.0&oauth_signature=ToVMRWpnl3YdxHRi8iIoBsqgurk%3D"
at org.opensocial.client.OpenSocialHttpClient.send
(OpenSocialHttpClient.java:118)
at org.opensocial.client.OpenSocialHttpClient.send
(OpenSocialHttpClient.java:89)
at org.opensocial.client.OpenSocialHttpClient.execute
(OpenSocialHttpClient.java:74)
at org.opensocial.client.OpenSocialHttpClient.execute
(OpenSocialHttpClient.java:45)
at org.opensocial.client.OpenSocialHttpClient.execute
(OpenSocialHttpClient.java:1)
at net.oauth.client.OAuthClient.invoke(OAuthClient.java:243)
at net.oauth.client.OAuthClient.invoke(OAuthClient.java:143)
at net.oauth.client.OAuthClient.getRequestToken(OAuthClient.java:101)
at org.opensocial.client.OpenSocialOAuthClient.getRequestToken
(OpenSocialOAuthClient.java:170)