Using with twitter

80 views
Skip to first unread message

Luís Azevedo

unread,
Oct 28, 2013, 8:05:47 PM 10/28/13
to google-oauth...@googlegroups.com

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 
 (); 
 params 
 . 
 token 
 = 
 token 
 ; 
 params 
 . 
 version 
 = 
 "1.0" 
 ; 
 params 
 . 
 consumerKey 
 = 
 TWITTER_CONSUMER_KEY 
 ; 
 params 
 . 
 signer 
 = 
 signer 
 ; 
 HttpRequestFactory 
 requestFactory 
 = 
 HTTP_TRANSPORT 
 . 
 createRequestFactory 
 ( 
 params 
 ); 
 HttpResponse 
 twResponse 
 = 
 requestFactory 
 . 
 buildGetRequest 
 ( 
 new 
 GenericUrl 
 ( 
 " https://api.twitter.com/1.1/account/verify_credentials.json 
" 
 )). 
 execute 
 (); 
 

The result is always:

WARNING: Authentication error: Unable to respond to any of these challenges: {} com.google.api.client.http.HttpResponseException: 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
Forward
0 new messages