Omniauth-facebook登录不起作用 [英] Omniauth-facebook login not working

查看:108
本文介绍了Omniauth-facebook登录不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用omniauth-facebook登录我的Rails应用程序时,出现以下错误.这是在localhost:3000上进行测试时:

When I try to login in my Rails app using omniauth-facebook, I'm getting the following error. This is when testing on localhost:3000:

不安全的登录被阻止:您无法获取访问令牌或从不安全的页面登录到此应用.尝试将页面重新加载为https://

Insecure Login Blocked: You can't get an access token or log in to this app from an insecure page. Try re-loading the page as https://

我看到了关于SO的其他最新帖子,但Facebook没有似乎不允许我在开发人员控制台中为此今天创建的应用程序更改对Web OAuth登录执行HTTPS"设置.我可以更改旧应用程序的设置.

I saw this other recent post on SO, but Facebook doesn't seem to be allowing me to change the "Enforce HTTPS for Web OAuth Login" settings in the developer console for this app that I created today. I can change that setting for old apps.

有关如何解决或解决此问题的任何想法?我将在生产环境中使用HTTPS,但只希望能够在开发环境中使用localhost(http).

Any ideas on how to fix this or get around it? I'll use HTTPS in production, but just want to be able to use localhost (http) in development.

推荐答案

在HTTPS模式下运行本地服务器可能有用很多次,而不仅仅是对Facebook api有用.

Running local server in HTTPS mode can be useful many times, not just only for the facebook api.

尽管如此,Rails仍然没有提供以SSL模式运行Rails服务器的简便方法.但是有几种方法可以实现:

Though, Rails still do not provide an easy way to run rails server in SSL mode. But there're several ways to achieve that:

使用thin服务器代替puma/webrick rails默认服务器

Use thin server instead of puma/webrick rails default one

thin服务器允许您以最小的努力在SSL模式下运行应用程序:

thin server allows you to run your application in SSL mode with a minimum effort:

编辑config/application.rb并添加:

config.force_ssl = true

启动thin服务器:

$ thin start --ssl

在此处查看有关此信息的完整信息:如何启用SSL在两分钟内完成Rails开发环境?

See full info about that here: How to enable SSL for Rails development environment in two minutes?

使用诸如ngrok

Use http tunnel tools like ngrok

ngrok 之类的工具可让您轻松地创建从本地主机到Internet的隧道-它还创建了两者http://https://端点供您使用:

Tools like ngrok allow you to create a tunnel form your localhost to the Internet with ease - it also creates both http:// and https:// endpoints for you:

$ rails s -p 3000
$ ./ngrok http 3000

ngrok by @inconshreveable                                                                                                                                            (Ctrl+C to quit)

Session Status                online                                                                                                                                                 
Session Expires               7 hours, 59 minutes                                                                                                                                    
Version                       2.2.8                                                                                                                                                  
Region                        United States (us)                                                                                                                                     
Web Interface                 http://127.0.0.1:4040                                                                                                                                  
Forwarding                    http://2608e936.ngrok.io -> localhost:3000                                                                                                             
Forwarding                    https://2608e936.ngrok.io -> localhost:3000    

复制生成的url(例如https://2608e936.ngrok.io并使用它来访问您的本地服务器.

Copy the generated url (like https://2608e936.ngrok.io and use it to access your local server.

这篇关于Omniauth-facebook登录不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆