views:

1093

answers:

2

I am currently trying to use the Grackle Ruby GEM to integrate with the Twitter API, but I have encountered a little snag.

I am attempting to perform a GET to twitter.com/oauth/request_token, but according to the OAuth spec I need to provide the following values:

  • oauth_consumer_key
  • oauth_signature_method
  • oauth_signature
  • oauth_timestamp
  • oauth_nonce

I am a little stumped, as at this point Twitter has only given me a Consumer Key and a Consumer Secret. Am I just going about this the hard way? Because I cannot figure out how to correctly populate those values. No matter what I supply Twitter keeps returning:

Failed to validate oauth signature and token

It sounds like my problem is just a general misunderstanding on how to properly integrate with Twitter and OAuth in general, and not so much the specifics of Grackle... but perhaps too much information is best in this case :-)

+1  A: 

First of all, you should probably be reading the latest OAuth rev, which is 1.0a. There are no differences when obtaining the request token though so you should be fine in that regard.

Apart from that, it looks like a combination of general misunderstanding of the OAuth process and the scope of Grackle:

The process of acquiring the access token and token secret are outside the scope of Grackle and will need to be coded on a per-application # basis. Grackle comes into play once you've acquired all of the above pieces of information (source).

So, I would first look towards a library that can get you an access token before continuing with Grackle. Moomerman's twitter_oauth looks like a good choice: http://github.com/moomerman/twitter_oauth

Hope that helps!

lemonad
Thanks!After I wrote my question I began experimenting with using a seperate OAuth gem, but I wasn't sure if I was just hacking around the issue or doing things the right way. Your answer helped assure me that I wasn't just 'hacking'.
Jason Whitehorn
+1  A: 

I encountered this same issue, and all the examples for the oauth gem online I could find were out of date. I wrote an explanation with sample code here, but the basic flow is:

  • Get a Request Token from Twitter and save the details
  • Send the user to Twitter with that token
  • Get the user back, use details and response from Twitter to generate an Access Token
  • Use the Access Token's token and secret with your Consumer token and secret to make API calls.
Allen Pike