Omniauth-facebook keeps reporting invalid_credentials

南笙酒味 提交于 2019-11-27 19:42:25

It seems like omniauth-facebook v1.4.1 introduced an issue with CSRF. A temporary fix is to just roll back to v1.4.0. In your Gemfile, change the omniauth-facebook line to:

gem 'omniauth-facebook', '1.4.0'

I've reported the issue: https://github.com/mkdynamic/omniauth-facebook/issues/73

I had a similar issue where it was working for 1 user but getting the Authenticating error for the 2nd user.

Disabling the Sandbox mode (Apps > Settings > Advanced) seems to have fixed it.

In your omniauth.rb add code:

OmniAuth.config.on_failure = Proc.new do |env| new_path = "/auth/failure"
 [302, {'Location' => new_path, 'Content-Type'=> 'text/html'}, []]
end

I've noticed that omniauth-oauth2 > 1.0.3 will cause a problem too, uninstalling higher version and keep omniauth-oauth2 1.0.3 solved the problem ..

I have this too.

Remove the JS script in your application.html.erb (but keep the fb-root div) will work. Anyway, the FB login screen won't be displayed in a popup window anymore, you'll be redirected to FB login then back to your site instead.

For anyone that's careless like I am,

Remember to switch you app out of Sandbox mode at developers.facebook before you deploy!

Sandbox mode will trigger the csrf error for everyone except the developer's account.

you may want to override OmniauthCallbacksController, and add this to logging:

class OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def failure_message
    exception = env["omniauth.error"]
    #add login here:
    Rails.logger.info "exception: #{exception.inspect}"
    error   = exception.error_reason if exception.respond_to?(:error_reason)
    error ||= exception.error        if exception.respond_to?(:error)
    error ||= env["omniauth.error.type"].to_s
    error.to_s.humanize if error
  end

  #other code ...
end

after ive added mine, i found "invalid ip..." issue,

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