Omniauth:回调未触发,用"无效凭证返回失败"

时间:2017-03-29 09:22:06

标签: ruby-on-rails facebook authentication callback omniauth

使用Omniauth gem实现的Rails应用程序中的facebook身份验证最近已停止工作。

问题是回调应该使用的控制器操作没有被触发,并且进程立即跳过失败,并且"无效的凭据"消息。

日志:

Started GET "/auth/facebook" for ::ffff:127.0.0.1 at 2017-03-29 11:12:29 +0200
Started GET "/auth/facebook/callback?code=<<code>>&state=<<state>" for ::ffff:127.0.0.1 at 2017-03-29 11:12:30 +0200
Started GET "/auth/failure?message=invalid_credentials&origin=<<origin>>&strategy=facebook" for ::ffff:127.0.0.1 at 2017-03-29 11:12:31 +0200
Started GET "/login" for ::ffff:127.0.0.1 at 2017-03-29 11:12:31 +0200
Processing by UserSessionsController#new as HTML

路线:

  match "/auth/failure" => redirect("/login"), :via => [:get, :post]
  match '/auth/:provider/callback' => 'user_sessions#create_omniauth', :via => [:get, :post]
  match '/auth/:provider/disconnect' => 'user_sessions#destroy_omniauth', :as => :destroy_auth, :via => :delete

任何想法可能出错?

修改 我在Google授权方面遇到了同样的问题。

1 个答案:

答案 0 :(得分:7)

使用以下内容将宝石更新为最新版本(omniauth 1.6.1和omniauth-facebook 4.0.0):

bundle update omniauth
bundle update omniauth-facebook

解决了这个问题。我将此留待将来参考。

修改

谷歌授权同样适用:

bundle update omniauth-google-oauth2