Skip to content
Branch: master
Go to file

Latest commit


Failed to load latest commit information.
Latest commit message
Commit time



Extension to OmniAuth, that brings cool view helper. All you have to do now is simply add one line to your template and you will see Facebook login button!


gem install oa-facebook

Add to environment.rb

config.gem 'oa-facebook'

Add to config/initializers/omniauth.rb:

#for rails3 projects
Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, <App ID>, <App Secret>
#for rails2 projects
ActionController::Dispatcher.middleware.use "OmniAuth::Builder" do
  provider :facebook, <App ID>, <App Secret>

If omniauth routes doesn't exist add them to config/routes.rb (e.g.):

match '/auth/:provider/callback' => 'authentications#create'
map.auth_callback '/auth/:provider/callback', :controller => :authentications :action => :create

Then use special helper method for generate Facebook button:

<%= facebook_login_button %>

Also you can pass a Hash as a parameter. Keys are:

  • native – render button with FBML or render image, true by default;

  • title – text in FBML button, or alt parameter of image tag, default is Login with Facebook;

  • image – address of an image, if native is set to false, default is ;

  • perms - permissions list. default is email,offline_access.

Finally you can right something like this:

<%= facebook_login_button(:native => false, :title => "Login from Facebook", :perms => "email, user_groups, user_events") %>

After click on the button popup window with auth-page will be shown and after user was signed in and added permissions for the application then user-data will be transfered with POST-request to /auth/mailru/callback path. In action with this path you can use params from request which body look like:

  'uid' => '100000882795341', # user Id from Facebook
  'provider' => 'facebook',
  'user_info' => {
    'nick' => 'igor.alexandrov',
    'email' => '',
    'name' => 'Igor Alexandrov',
    'first_name' => 'Igor',
    'last_name' => 'Alexandrov',
    'image' => '',
    'urls' => {
      'Facebook' => ''
    'location' => 'Tver'


Contributing to oa-facebook

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet

  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2011 Igor Alexandrov. See LICENSE.txt for further details.


OmniAuth extension for easy Facebook login integration




You can’t perform that action at this time.