尝试取消弹出窗口时出现Omniauth + facebook错误

man*_*ale 6 facebook callback omniauth ruby-on-rails-3

我在我的rails应用程序中使用omniauth-facebook gem允许用户通过facebook登录/签名.它运作良好.但我的问题是,当我点击取消按钮时,我收到以下错误

(facebook) Callback phase initiated.
(facebook) Authentication failure! invalid_credentials: OmniAuth::Strategies::OAuth2::CallbackError, OmniAuth::Strategies::OAuth2::CallbackError


Started GET "/auth/facebook/callback?error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request." for 127.0.0.1 at 2012-05-18 11:42:36 +0530
Run Code Online (Sandbox Code Playgroud)

怎么了?添加/ auth/failure =>'pages #home '也无法正常工作.请帮忙

njo*_*den 6

请查看https://github.com/intridea/omniauth/wiki/FAQ上的最后一节,看看是否有帮助.它建议添加

OmniAuth.config.on_failure = Proc.new { |env|
  OmniAuth::FailureEndpoint.new(env).redirect_to_failure
}
Run Code Online (Sandbox Code Playgroud)

到您的omniauth初始化程序.这在我当地工作,然后你只需要定义你的/ auth/failure路线和行动.


Her*_*ess 0

我在本地调试(localhost)时遇到了同样的问题。
在公共网址上它有效,它可能需要 FB 才能“看到”你。

您可以在公共网址上进行测试,也可以使用一些隧道之王(localtunnel是一个非常简单的示例)。

华泰