简体   繁体   中英

How do I setup omniauth-facebook on an already existing omniauth and devise rails app?

So, I followed the instructions as mentioned here http://railscasts.com/episodes/235-devise-and-omniauth-revised and successfully setup the the sign in and sign up with twitter option. Now I am trying to setup facebook. Using the gem 'omniauth-facebook' . After installing it. I then added to /config/initializers/devise.rb file

config.omniauth :facebook, ENV["FB_APP_ID"], ENV["FB_SECRET_ID"]

Now, when I try to sign in with facebook. I get the error -

ArgumentError in OmniauthCallbacksController#facebook

wrong number of arguments(3 for 2)

I was doubting an error might show up. But not sure how to fix it.

My controller and user model are same as mentioned here - http://railscasts.com/episodes/235-devise-and-omniauth-revised

What am i missing?

UPDATE: I did change this in the user.rb model file

instead of alias_method :twitter, :all I made it alias_method :twitter, :facebook :all

Thanks

This worked for me:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, 'FB_APP_ID', 'FB_SECRET_ID'

but i didn't use devise, so just try to remove the ENV .

Also read here about all the options and some fails you may encounter:

https://github.com/plataformatec/devise/wiki/OmniAuth%3a-Overview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM