Devise + Omniauth call action passthru on login Facebook

荒凉一梦 提交于 2019-12-04 16:25:00

I just flailed with the exact same problem for hours, trying everything including doing the exact same process on a different branch with github oauth, which worked without a problem. What finally worked for me was changing the hash of arguments I was passing to config.omniauth in devise.rb after the app token and secret. It was name: 'google' that was doing it. Commented it out and it works:

config.omniauth :google_oauth2, 'ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"],
   {
    # name: 'google',
    scope: 'calendar, plus.login plus.me'
  }

Whether the id and secret are hard coded in has no effect. I didn't try it, but :name seems like it is used as an alias for the provider to use elsewhere in the code in place of :google_oauth2. Uncommenting it and changing it (redundantly) to name: google_oauth2 works. I'm sure you've either solved it or moved on after a year but I hope this helps someone in the future.

onmiauth-google-oauth2 0.2.5

devise 3.4.0

rails 4.1.6

The passthru route is an old relic from the omniauth past.

Just set your routes like this:

devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }

Did you add the configuration in devise.rb ?
you need to declare the provider in your (config/initializers/devise.rb) and require it

require "omniauth-facebook" 
config.omniauth :facebook, "APP_ID", "APP_SECRET"

You will need to restart the server also.

In my case, we added the gem omniauth-rails_csrf_protection but we were still trying to access the authorize endpoints using GET methods. Replacing those GET calls by POST requests (with the CSRF token) solved it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!