New Rails Plugin Available: YAML Twitter OAuth

Written by pete

Topics: Uncategorized

When I build Twitter OAuth apps, I usually register three apps. One for development purposes, one for staging and user-acceptance testing, and the production application. Each of these registered apps will have a different Twitter OAuth Consumer Token and Secret. Instead of writing procedural code to set the right tokens up for each environment, or setting them in the various environment/*.rb files, I prefer to set them up declaratively like you do in database.yml.

I’ve extracted the basic code i use to do this and published it as a simple plugin called yaml_twitter_oauth.

It allows you to set up your consumer tokens like this:

defaults: &defaults
  request_token_url: http://twitter.com/oauth/request_token
  access_token_url: http://twitter.com/oauth/access_token
  authorize_url: http://twitter.com/oauth/authorize

development:
  <<: *defaults
  consumer_key: 12345678
  consumer_secret: this-is-your-application-secret

staging:
  <<: *defaults
  consumer_key: 12345678
  consumer_secret: this-is-your-application-secret

production:
  <<: *defaults
  consumer_key: 12345678
  consumer_secret: this-is-your-application-secret

It’s also useful if you want to regenerate your secret key and need a simple declarative way to update it.

To install the plugin:

 script/plugin install git://github.com/peteonrails/yaml_twitter_oauth.git

Enjoy!

  • thinktogether

    How to use?

  • http://blog.peteonrails.com peteonrails

    thinktogether:

    You should read the README first. It's got a reasonably good introduction. If you have questions after reading it, let me know.

    http://github.com/peteonrails/yaml_twitter_oauth

  • thinktogether

    Peteonrails ,Thank you.

    : )

  • thinktogether

    Peteonrails ,Thank you.

    : )