Omniauth:回调未触发,returns 失败 "invalid credentials"

Omniauth: callback not firing, returns failure with "invalid credentials"

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

问题是应该由回调使用的控制器操作没有被触发,进程立即跳到失败并显示 "invalid credentials" 消息。

日志:

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 授权方面遇到了同样的问题。

将 gems 更新到最新版本(omniauth 1.6.1 和 omniauth-facebook 4.0.0):

bundle update omniauth
bundle update omniauth-facebook

问题已解决。我将此留作将来参考。

编辑:

同样的事情适用于 google 授权:

bundle update omniauth-google-oauth2