2011-11-13 52 views
1

我跟在瑞安贝茨Omniauth Part1 railscats http://railscasts.com/episodes/235-omniauth-part-1。我把Twitter和Facebook的身份验证与他们的秘密号码,当我尝试通过Facebook(AUTH/Facebook的)来验证我得到这个错误:当我尝试使用omniauth通过Facebook进行身份验证时出错

{ 
    "error": { 
     "message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.", 
     "type": "OAuthException" 
    } 
} 

,当我尝试通过Twitter(AUTH /叽叽喳喳)我得到验证这401未经授权的回应。我不知道如何纠正它

谢谢我纠正在twitter URL回调字段和facebook我的网站字段中输入http://127.0.0.1:3000。但现在当我尝试使用Facebook进行身份验证时,出现此错误:

OpenSSL::SSL::SSLError

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

我该如何解决它?我解决了将OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE开发出来的问题.rb

回答

1

当您的服务器运行在http协议上时出现该错误。您需要添加这段代码在your_project /脚本/导轨前APP_PATH

require 'rubygems' 
require 'rails/commands/server' 
require 'rack' 
require 'webrick' 
require 'webrick/https' 

module Rails 
    class Server < ::Rack::Server 
     def default_options 
      super.merge({ 
       :Port => 3000, 
       :environment => (ENV['RAILS_ENV'] || "development").dup, 
       :daemonize => false, 
       :debugger => false, 
       :pid => File.expand_path("tmp/pids/server.pid"), 
       :config => File.expand_path("config.ru"), 
       :SSLEnable => true, 
       :SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE, 
       :SSLPrivateKey => OpenSSL::PKey::RSA.new(
         File.open("/path_to_your/privatekey.pem").read), 
       :SSLCertificate => OpenSSL::X509::Certificate.new(
         File.open("/path_to_your/servercert.crt").read), 
       :SSLCertName => [["CN", WEBrick::Utils::getservername]] 
      }) 
     end 
    end 
end 

要生成自签名证书阅读本教程http://www.akadia.com/services/ssh_test_certificate.html(步骤1至4)或本www.tc.umn.edu/~brams006/selfsign.html

更新轨后脚本更改url从http://127.0.0.1:3000https://127.0.0.1:3000

+0

非常感谢!我更正了它在development.rb中的development.rb中放置了OpenSSL :: SSL :: VERIFY_PEER = OpenSSL :: SSL :: VERIFY_NONE,但我认为创建一个ssl安全连接更好。 – TomasMax

1

我在Twitter开发中经常遇到这个问题。

该问题可能是您的应用设置中的回调网址。尝试将其设置为:

http://127.0.0.1 

然后重试。如果它不起作用http://localhost:3000然后尝试从http://127.0.0.1:3000

Facebook的问题也可能是应用程序设置中的回调URL。对于Facebook,我的site url设置为:http://localhost:3000/

+0

感谢与推特我改正它,但与Facebook没有。在我必须把http:// localhost:3000/??的FAcebbok appa options中 – TomasMax

+0

https://developers.facebook.com/apps - >编辑设置 - >网站 – Gazler

+0

我在过去使用Webbrick也遇到了问题。我不确定这是否是答案,只是买方要小心。我在Gemfile中转换为细薄的gem'thin',然后rails变薄。 –

相关问题