Teach Me To Code
Writing Code is the Easy Part
by Charles Max Wood on October 6, 2010
Twitter just turned off Basic Auth and is forcing application developer to use OAuth. Here is a demonstration of how to add Twitter OAuth to your Ruby on Rails Application.
Download 90.9 MB
Download (iPod & iPhone) 45.6 MB
Ruby on Rails,
Man, you are a saviour. I almost pulled the last strand of my bald hair out trying to figure this out from the code the Twitter gem provides.
Glad it helped. I know what it’s like to be losing your hair. It doesn’t help when you’re pulling it out over something like this.
Any other ways I can preserve your diminishing hair?
hey buddy, great stuff. Just wanted to let you know that perhaps you should name your page titles and seo your entries so people can find them easier – there are tonnes of people just looking to solve this problem. take care.
silly question, how does the ‘finalize’ action get triggered in the controller in this case, was it routed manually or by default?
The finalize action is set in the .set_callback_url call.
Just thought I would point out Twitter::OAuth was removed in newer versions of the gem.
Hi Charles, thx for the screen cast.
I’m a total noob (in ror) and get stuck in the middle of the tutorial (uninitialized constant TwitterController::Twitter).
Just to make sure i’m not crazy, which Twitter Gem are you using ?
I’m using the Twitter gem.
In your Gemfile, you should see:
Thx for the quick answer. As said, i’m a noob and jumping from tutos to tutos, i missed the main one : gem install [gem] needs a gemfile modif and a bundle install
Thx again !
Yes, in Rails 3, you’ll need to modify your Gemfile and then run `bundle install` to get the gem included.
Charles, this is a great tutorial! However part of the functionality is no longer there because the Twitter::OAuth class has been removed.
“The Twitter::OAuth class has been removed. This class was just a wrapper to
get access tokens via the oauth gem. Given that there are a variety of gems
that do the same thing (twitter-auth, omniauth, and devise, to name a few)
we decided to decouple this functionality so you can use the authentication
library of your choosing, or none at all. ”
What type of fix would this require to get your solution working again? Thanks for the help.
Drew, I’ve done similar stuff with the twitter_oauth gem. https://github.com/moomerman/twitter_oauth
I’ve also used the oauth gem, but it takes a little more plumbing to get it working.
Previous post: TMTC 35 – Joe Ferris from Thoughtbot
Next post: Why I Went Freelance
Get smart with the Thesis WordPress Theme from DIYthemes.