Hi developers!
I've recently tried to establish oauth interconnection between my
server and my robot. First it did not work at all, and i tried to
find errors in my server's oauth implementation, but finally i had to
change OAuthServiceImpl.java from Wave API library. Please, take a
look, may be these changes are really necessary:
I changed:
1.private String getAndStoreRequestToken() {
// Get the request token.
try {
oauthClient.getRequestToken(accessor);
} catch (IOException e) {
LOG.severe("Could not reach service provider to get request
token: " + e);
} catch (OAuthException e) {
LOG.severe("Unable to fetch request token. Authentication error:
" + e);
} catch (URISyntaxException e) {
LOG.severe("Unable to fetch request token. Invalid url: " + e);
}
// Store request token in Datastore via a tokenData object.
String requestToken = accessor.requestToken;
OAuthUser u=new OAuthUser(userRecordKey, requestToken);
u.setTokenSecret(accessor.tokenSecret);
storeUserProfile(u);
return accessor.requestToken;
}
Here i added saving of token secret
u.setTokenSecret(accessor.tokenSecret);
2. private String exchangeTokens(OAuthUser userProfile) {
// Re-initialize an accessor with the request token and secret
token.
// Request token needs to be in access token field for exchange to
work.
accessor.accessToken = userProfile.getRequestToken();
accessor.tokenSecret = userProfile.getTokenSecret();
// Perform the exchange.
LOG.warning(accessor.tokenSecret);
String accessToken = null;
String tokenSecret = null;
try {
OAuthMessage message =
oauthClient.invoke(accessor, GET,
accessor.consumer.serviceProvider.accessTokenURL, null);
accessToken = message.getToken();
tokenSecret = message.getParameter(OAuth.OAUTH_TOKEN_SECRET);
} catch (IOException e) {
LOG.warning("Failed to retrieve access token,cause: " +
e.getMessage());
} catch (OAuthException e) {
LOG.warning("Failed to retrieve access token: " +
e.getMessage());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
if (accessToken != null) {
// Store the access token in the user profile object and put
profile back
// in the datastore.
userProfile.setAccessToken(accessToken);
userProfile.setTokenSecret(tokenSecret);
storeUserProfile(userProfile);
}
return accessToken;
}
Here i added setting of token secret in accessor accessor.tokenSecret
= userProfile.getTokenSecret();
After these modifications all troubles disappeared and OAuth worked
ok.
Thanks, Evgeniy
--
You received this message because you are subscribed to the Google Groups
"Google Wave API" group.
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-wave-api?hl=en.