OAuth with the Twitter Gem

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

{ 24 comments… read them below or add one }

Igbanam Ogbuluijah November 1, 2010 at 12:52 am

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.

Thanks!

Reply

Charles Max Wood December 24, 2010 at 9:54 pm

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?

Reply

Igbanam Ogbuluijah November 1, 2010 at 12:52 am

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.

Thanks!

Reply

Charles Max Wood December 24, 2010 at 9:54 pm

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?

Reply

Tzuming January 26, 2011 at 2:55 am

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.

Reply

Tzuming January 26, 2011 at 2:55 am

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.

Reply

Tzuming January 26, 2011 at 3:30 am

silly question, how does the ‘finalize’ action get triggered in the controller in this case, was it routed manually or by default?

Reply

Charles Max Wood January 26, 2011 at 3:39 pm

The finalize action is set in the .set_callback_url call.

Reply

Tzuming January 26, 2011 at 3:30 am

silly question, how does the ‘finalize’ action get triggered in the controller in this case, was it routed manually or by default?

Reply

Charles Max Wood January 26, 2011 at 3:39 pm

The finalize action is set in the .set_callback_url call.

Reply

Andrew February 7, 2011 at 4:51 am

Great video!

Just thought I would point out Twitter::OAuth was removed in newer versions of the gem.

http://groups.google.com/group/ruby-twitter-gem/browse_thread/thread/be600e4ffc5f6646#

Reply

Andrew February 7, 2011 at 4:51 am

Great video!

Just thought I would point out Twitter::OAuth was removed in newer versions of the gem.

http://groups.google.com/group/ruby-twitter-gem/browse_thread/thread/be600e4ffc5f6646#

Reply

Laurent Kretz February 16, 2011 at 10:43 am

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 ?

Thx !

Reply

Charles Max Wood February 16, 2011 at 5:37 pm

I’m using the Twitter gem.

In your Gemfile, you should see:

gem ‘twitter’

Reply

Laurent Kretz February 16, 2011 at 5:41 pm

Hi Charles,
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 !

Reply

Charles Max Wood February 16, 2011 at 7:02 pm

Yes, in Rails 3, you’ll need to modify your Gemfile and then run `bundle install` to get the gem included.

Reply

Laurent Kretz February 16, 2011 at 10:43 am

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 ?

Thx !

Reply

Charles Max Wood February 16, 2011 at 5:37 pm

I’m using the Twitter gem.

In your Gemfile, you should see:

gem ‘twitter’

Reply

Laurent Kretz February 16, 2011 at 5:41 pm

Hi Charles,
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 !

Reply

Charles Max Wood February 16, 2011 at 7:02 pm

Yes, in Rails 3, you’ll need to modify your Gemfile and then run `bundle install` to get the gem included.

Reply

Drew Berkowitz February 17, 2011 at 12:07 am

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.

Reply

Charles Max Wood February 17, 2011 at 2:15 am

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.

Reply

Drew Berkowitz February 17, 2011 at 12:07 am

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.

Reply

Charles Max Wood February 17, 2011 at 2:15 am

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.

Reply

Leave a Comment