Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OAuth (Twitter, Facebook, LinkedIn, etc) on Rails

I would like to connect to those applications which provided OAuth API (such as fb, twitter).

Is there a relatively easier way to integrate those APIs?

I have successfully used linkedin gem which can connect to LinkedIn OAuth API. But I really don't want to install a gem for dealing with a single application, where those applications provided similar OAuth APIs.

like image 341
PeterWong Avatar asked Jun 28 '10 09:06

PeterWong


1 Answers

Since Oct 2010, someone has come up with a gem called OmniAuth. It packages together a number of different identity providers into a Rack middleware. It specifically does not handle authorization or persistence -- that is left up to you. It's probably the best option out right now, especially if you don't plan on using classic username/password authentication (though OmniAuth can handle it).

OmniAuth will handle identification from Facebook, Twitter, Google, LinkedIn, 37Signals, and Github. See below for a complete list as of this posting.

Since this is a Rack middleware, it is possible to use this with Devise and AuthLogic. Because of its modularity, it should be easy to use this with pure-Restful-API Rails/Sinatra apps (no direct HTML rendering) that talk to mobile apps that is gaining in popularity without pulling in the extra code from Devise and AuthLogic.

The best tutorial for getting started is the blog post written for Rails Rumble on getting authentication up and running quickly: http://blog.railsrumble.com/blog/2010/10/08/intridea-omniauth

Ryan Bates also has a few Railscasts about OmniAuth:

  • http://railscasts.com/episodes/235-omniauth-part-1
  • http://railscasts.com/episodes/236-omniauth-part-2
  • http://railscasts.com/episodes/241-simple-omniauth

As of this posting, these are the following providers coming out of the box (based on https://github.com/intridea/omniauth/tree/dc44c54d80ca0b49d1f63bbbf21165a7515fd41d)

OAuth/OAuth2:

  • bitly
  • dailymile
  • doit
  • dopplr
  • evernote
  • facebook
  • foursquare
  • github
  • goodreads
  • google
  • gowalla
  • hyves
  • identica
  • instagram
  • instapaper
  • linked_in
  • meetup
  • miso
  • mixi
  • netflix
  • smug_mug
  • sound_cloud
  • 37 Signals
  • trade_me
  • trip_it
  • twitter
  • type_pad
  • vimeo
  • xauth
  • yahoo
  • you_tube

OpenId:

  • Google App (Marketplace integration)
  • Generic OpenID

HTTP Basic:

  • 37 Signals Campfire
  • 37 Signals Basecamp
  • Generic HTTP Basic auth

Enterprise:

  • Central Authentication Service (CAS)
  • LDAP

Other:

  • Windows Live
  • Flickr
like image 185
Ho-Sheng Hsiao Avatar answered Oct 04 '22 16:10

Ho-Sheng Hsiao