Hi,
I've been using OAuth in my Android app, with mostly good results. I find out that the occasional failures were due to my use of the DefaultOAuthProvider, rather than CommonsHttpOAuthProvider class. Signpost states this on their project page, http://code.google.com/p/oauth-signpost/
So I switched to CommonsHttpOAuthProvider, requiring use of a newer signpost version, and now I can't authenticate to myspace at all. I had to make the following changes to the myspace sdk, but it still hangs on retrieveRequestToken.
// snippet from MSOAuth.java
private void initConsumer(String apiKey, String apiSecret) {
// update to use signpost-commonshttp4-1.2.1.1
// mOAuthConsumer = new CommonsHttpOAuthConsumer(apiKey, apiSecret, SignatureMethod.HMAC_SHA1);
Log.v("MSOAuth","initConsumer("+apiKey+","+apiSecret+")");
mOAuthConsumer = new CommonsHttpOAuthConsumer(apiKey, apiSecret);
mOAuthConsumer.setMessageSigner(new HmacSha1MessageSigner());
}
private void initProvider() {
Log.v("MSOAuth","initProvider");
String requestedPermissions = MSSession.getSession().getRequestedPermissions();
String authUrl = (requestedPermissions == null) ? OAUTH_AUTHORIZATION_URL : OAUTH_AUTHORIZATION_URL + "?myspaceid.permissions=" + requestedPermissions;
// update to use signpost-commonshttp4-1.2.1.1
// mOAuthProvider = new DefaultOAuthProvider(OAUTH_REQUEST_TOKEN_URL, OAUTH_ACCESS_TOKEN_URL, authUrl);
mOAuthProvider = new CommonsHttpOAuthProvider(OAUTH_REQUEST_TOKEN_URL, OAUTH_ACCESS_TOKEN_URL, authUrl);
}
public String retrieveRequestToken(String callbackUrl) throws OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException {
// update to use signpost-commonshttp4-1.2.1.1
// String authUrl = mOAuthProvider.retrieveRequestToken(callbackUrl);
Log.v("MSOAuth","retrieveRequestToken("+callbackUrl+")");
// the next line times out
String authUrl = mOAuthProvider.retrieveRequestToken(mOAuthConsumer, callbackUrl);
Log.v("MSOAuth","authUrl:"+authUrl);
this.mRequestToken = getToken();
Log.v("MSOAuth","mRequestToken:"+getToken());
this.mRequestTokenSecret = getTokenSecret();
Log.v("MSOAuth","mRequestTokenSecret:"+getTokenSecret());
return authUrl;
}
public void retrieveAccessToken(String verifier) throws OAuthMessageSignerException, OAuthNotAuthorizedException, OAuthExpectationFailedException, OAuthCommunicationException {
// update to use signpost-commonshttp4-1.2.1.1
// mOAuthProvider.retrieveAccessToken(verifier);
mOAuthProvider.retrieveAccessToken(mOAuthConsumer, verifier);
}
I'm not getting any response, though I'm still able to authenticate to twitter with no issues, so it seems that OAuth is implemented correctly. Even when I switch back to using DefaultOAuthProvider, it won't authenticate with MySpace. Why can't I authenticate anymore?