facebook 的omniauth 无法用于生产
我正在我的rails应用程序中使用omniauth,我已经使用facebook和twitter按钮进行签名,当我将facebook放入网站url归档localhost:3000时,一切正常,但是当我将网站上传到heroku时并将站点 URL 更改为 sitename.heroku.com,twiiter 登录按钮可以工作,但 facebook 按钮不起作用......
i'm working with omniauth in my rails app, i have sign with facebook and twitter button, when i'm putting in facebook in the site url filed localhost:3000, all is working, but when i'm uploading the site to heroku and changing in the site url to sitename.heroku.com, the twiiter login button working but the facebook button don't working...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能需要向我们提供更多信息(Facebook 按钮不起作用是什么意思?您是否收到错误消息?如果是这样,是什么?您的日志说了什么?)
但是,这很可能是您的问题:在heroku 上使用omniauth Facebook 身份验证存在一个已知问题。您需要在 config/initializers/omniauth.rb 文件中添加对 SSL 证书文件的显式引用。更改您的 facebook 配置行以包含“client_options”哈希,如下所示:
You probably need to give us more information (What do you mean the facebook button isn't working? Are you getting an error message? If so, what? What are your logs saying?)
BUT, there's a good chance this is your problem: there is a known issue using omniauth facebook authentication on heroku. You need to add an explicit reference to the SSL certificates file in the config/initializers/omniauth.rb file. Change your facebook config line to include the 'client_options' hash like so:
如果您想在本地主机上进行测试并保持生产环境正常运行,您可以:
1- 创建一个仅用于开发目的的新 Facebook 应用程序
2- 将站点 URL 字段设置为:
http://localhost:3000/
3- 然后编辑您的
/config/initializers/omniauth.rb
文件以匹配以下内容:最后重新启动
rails server
,您应该能够通过新应用程序登录。If you want to test on local host and keep your production environment working you can:
1- Create a new Facebook app only for development purposes
2- Set the Site URL field to:
http://localhost:3000/
3- Then edit your
/config/initializers/omniauth.rb
file to match the following:Finally relaunch
rails server
and you should be able to login through your new app.