Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Sign in with Twitter OAuth: A Rails Generator plugin
branch: master
Failed to load latest commit information.
generators added some exception handling
lib/twitter_authentication staged plugin for alpha testing
Rakefile staged plugin for alpha testing
install.rb staged plugin for alpha testing


                            Twitter Authentication

This is a "Sign in with Twitter"-oauth authorization generator for rails, based
closely on the restful_authentication plugin by Rick Olson which can be found at

"Sign in with Twitter" is the pattern of authentication that allows users to
connect their Twitter account with third-party services in as little as one

Step 1 - Installation:

  ./script/plugin install git://

Step 2 - Generate Authentication System:

  ./script/generate twitter_authenticated user sessions

  The first parameter specifies the model that bootstraps the twitter account
  (typically a user or account model).

  The second parameter specifies the sessions controller name.  This is the
  controller that handles the actual login/logout function on the site.

Step 3 - Migrate User Account Model

  View the created migration and see if it meets your need. This model bootstaps
  itself onto the users twitter account and caches all user details. Any additional
  fields you require to store should be added to the migration at this time.

  ./rake db:migrate RAILS_ENV=development|production

Step 4 - Register Application with Twitter:

  Visit and register a new application.

  Point the Callback url to: http://your.application.url/sessions/callback

  Upon completion you will receive a consumer key and secret you will need to
  add to config/twitter_oauth.yml

Step 5 - Add Authentication to your Controllers

  To add authentication to protect your controllers use a before_filter


    before_filter :login_required

* Now your application should be ready to go? *


* Twitter gem by John NuneMaker
  an API wrapper for Twitter and Twitter Search API's

  gem install twitter


* login_required

  Use on controllers to autheticate access to individual pages.


  class UsersController < ApplicationController
    before_filter :login_required, :except => 'index'

* authorized?, logged_in?

  Show the logged in state of the user.


       Copyright (c) 2009 Corban Brook, released under the MIT license
Something went wrong with that request. Please try again.