Using with twitter

Skip to first unread message

Luís Azevedo

Oct 28, 2013, 8:05:47 PM10/28/13

I'm having issues invoking twitter REST API using Google Oatuh Java Client. I'm able to do the first steps correctly:

  1. Set the authorization url
  2. Get the temporary token
  3. Generate the final token

Then the Oatuh javadoc says:

Use the stored access token to authorize HTTP requests to protected resources by setting the OAuthParameters.token and using OAuthParameters as the HttpRequestInitializer.

It's in this step that I have issues. First of all if I only set the OAuthParameters.token value I'll get a null exception because the signer isn't set so what I presently have is:

OAuthParameters params = new OAuthParameters();
HttpRequestFactory requestFactory = HTTP_TRANSPORT.createRequestFactory(params);
HttpResponse twResponse = requestFactory.buildGetRequest(new GenericUrl("")).execute();

The result is always:

WARNING: Authentication error: Unable to respond to any of these challenges: {} 401 OK {"errors":[{"message":"Could not authenticate you","code":32}]}

If I try the Authorization header given by twitter Oauth tool through a REST chrome extension tool it works perfectly so it's not an account issue. When I change it for the Authorization header value computed by the Google Oauth Java client library it doesn't work.

I don't get what I'm doing wrong.

Reply all
Reply to author
0 new messages