使用omniauth-facebook“无效凭据”进行设计
我正在尝试通过omniauth-facebook 使 Facebook 身份验证与 Devise 一起使用,我已按照此处的说明进行操作:https://github.com/plataformatec/devise/wiki/OmniAuth%3a-Overview
当我点击“使用 Facebook 登录”链接时,我会被重定向到 Facebook 进行登录并接受所请求的权限。
然后我被带回到 /users/sign_in 并显示错误消息“无法从 Facebook 授权您,因为“无效凭据””
查看服务器日志,重定向来自“/users/auth/facebook/callback?code=[long text string]” 正在使用 Users::OmniauthCallbacksController#failure 进行处理,而不是使用 Users::OmniauthCallbacksController#facebook 进行处理,正如我所期望的那样(如果它有效的话)。
任何关于为什么会发生这种情况以及如何解决它的建议都非常感谢。
I'm trying to get Facebook authentication working with Devise through omniauth-facebook, I've followed the instructions here: https://github.com/plataformatec/devise/wiki/OmniAuth%3a-Overview
When I follow the login with Facebook link I am redirected to Facebook to login and accept the requested permissions.
I am then taken back to /users/sign_in with the error message "Could not authorize you from Facebook because "Invalid credentials""
Looking at the server logs the redirect comes from "/users/auth/facebook/callback?code=[long text string]" which is being processed with Users::OmniauthCallbacksController#failure rather than Users::OmniauthCallbacksController#facebook as I would have expected if it had worked.
Any suggestions as to why this is happening and how to resolve it much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我也遇到了同样的问题。对我来说,原因是我在 config/initializers/devise.rb 中定义了这一行:
应用程序 ID 和应用程序密钥是为我的测试 Facebook 应用程序和生产应用程序定义的。修复这些 id:s 现在就解决了问题。
Ok, I had the very same issue. The reason for me turned out that I had defined this line in config/initializers/devise.rb:
The app id and app secret were defined for my test Facebook app, and for production one. Fixing those id:s now fixed the problem.
Facebook 将协议从 oauth 更改为 oauth2
主要区别在于凭证(id、token、name..)现在打包成一个哈希值。你应该解析。
facebook changes protocol from oauth to oauth2
the main difference that credentials (id, token, name..) now packaged into one hash. You should parse.