Search code examples
androidtwitteroauthscribe

Android with Scribe error Could not authenticate you code:32


I'm creating app for android using scrible 1.3.5 and have a problem getting response from "https://api.twitter.com/1.1/account/verify_credentials.json" but getting error

"{"errors":[{"message":"Could not authenticate you","code":32}]}"

There is a separate activity, first of all there is a creation of service

service = new ServiceBuilder()
.provider(TwitterApi.SSL.class)
.apiKey(getString(R.string.twitter_customer_key))
.apiSecret(getString(R.string.twitter_customer_secret))
.callback(getString(R.string.twitter_callback_url))
.build();

After that in AsyncTask I'm getting request token and authUrl

requestToken = service.getRequestToken();
service.getAuthorizationUrl(requestToken);

After that in my implementation of WebViewClient I'm getting acess token

Uri uri = Uri.parse(url);
final Verifier verifier = new Verifier(uri.getQueryParameter("oauth_verifier"));
(new AsyncTask<Void, Void, Token>() {
@Override
protected Token doInBackground(Void... params) {
Token accessToken = service.getAccessToken(requestToken, verifier);
OAuthRequest request = new OAuthRequest(Verb.GET, "https://api.twitter.com/1.1/account/verify_credentials.json");
service.signRequest(accessToken, request);
Response response = request.
Log.d("TWITTER RESPONSE", response.getBody());
return accessToken;
}

@Override
protected void onPostExecute(Token accessToken) {
// AccessToken is passed here! Do what you 
finish();
}
}).execute();

What am I doing wrong, maybe there is some way to find out anything from these error message, I can provide any more information


Solution

  • I'm really sorry, but the code is fine, the problem was with the twitter api key. It was copied with some changes, so it was wrong.

    The code above worked fine for me.