0
votes

All I want to do is display tweets in my web application's footer, however I want to integrate twitter a lot more with my app in the future, so I don't want to resort to just using their little jquery snippet at the top of the page. However, I am having huge difficulty in aquiring the keys needed, and to be honest, I'd really appreciate some help with some of the jargon.The fact that you have to create a twitter application in order to recieve tweets from the api was completely alien to me and I'd like someone to clarify what I need to do below.

Here's a list of how I think things should be done, but please update this list because it doesn't seem to be working for me. Imagine I'm trying to create a twitter feed for the tweets belonging to the account awesome_kittens.

  1. visit https://dev.twitter.com/ and sign in as awesome_kittens
  2. click the my_applications dropdown
  3. click create new app button
  4. find the app's consumer_key
  5. find the app's consumer_secret
  6. find the app's oauth_token
  7. find the app's oauth_secret
  8. Use this information to connect to the api

I'm using Ruby on Rails, so in my case for step 8 I'd create an initilizer and do the below:

Twitter.configure do |config|
  config.consumer_key = 'consumer_key'
  config.consumer_secret = 'consumer_secret'
  config.oauth_token = 'your_oauth_token_here'
  config.oauth_token_secret = 'your_oauth_token_secret_here'
end

Confused by step 3. Is the application I've created magically linked to my awesome_kittens account? Why can I create an infinite number of different applications when signed in as awesome_kittens when I just want one for awesome_kittens? How do I make an application linked to awesome_kittens?

Completely stumped by steps 4, 5, 6 and 7. I've looked high and low and cannot find this information anywhere. No where. The only keys I can find are API key and API secret. Not a hint of oauth.

I'm using the Twitter Gem. Is this the best Gem for the job? Maybe I want my rails app to be able to tweet on the awesome_kittens account? What's the best job here?

2
API Key is Consumer Key, API Secret is Consumer Secret. - Yuva Raj

2 Answers

0
votes

Here is my understanding of it--- your application needs to have a set of keys to interact with twitter.

The Consumer Keys

These keys are set up when you create an application with twitter. These are the consumer keys.

These keys are going to be used for your application to interact with Twitter's API. All of your requests will be signed with your public and private key. You never expose your private key-- but your public key can get exposed. You probably don't have to worry about the details because whatever gem you use will take care of the details. (Internally there is a handshaking process that would give you broken wrist if they were actual handshakes)

The OAuth keys

So how about the oauth tokens. The set of oauth token keys give YOUR application the ability to do things to a twitter account. It might be the account you used to set up the consumer key with. But it could just as easily be another account.

Think of the consumer keys as the keys the keys which enable your application to interact with the twitter api and think of the oauth keys as the keys which will let your application interact with your twitter account.

Multiple OAuth Key Sets

I know it can be a bit confusing-- and it probably makes more sense when you let the users of your application give permission for your application to interact with twitter through your application. In that case there would be a number of Oauth key sets-- each one of them corresponding to a different twitter account.

That make any sense?

0
votes

There are 2 ways in which an app can authenticate (using oauth) to Twitter:

  • purely application only authentication. You just need application credentials for that, which are the "consumer_key" and "consumer_secret" above
  • end user authentication in the application's content. For this your require the application credentials as above along with user credentials in the app's content, which are oauth_token and oauth_token_secret above

If you want to call in just the application context, then consumer key is adequate. You'd be rate limited per application and won't be able to access user data that is not public.

With the user token context, you'd be rate limited per user token, this is desirable if you have several users and need to make more calls than application context rate limiting allows. This way you can access private user data. This would require you to build a workflow to obtain user tokens in your application's context.

In your case, it seems like application-only authentication using the consumer_key and consumer_secret are adequate for now.