1

我关注了 Ryan Bates Omniauth Part1 railscats http://railscasts.com/episodes/235-omniauth-part-1。我将 twitter 和 Facebook 身份验证与他们的密码一起使用,当我尝试通过 Facebook (auth/facebook) 进行身份验证时,我收到此错误:

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

当我尝试通过 twitter (auth/twitter) 进行身份验证时,我收到了 401 Unauthorized 响应。我不知道我该如何纠正它

谢谢我更正http://127.0.0.1:3000了在 twitter URL 回调字段和 facebook 我的网站字段中的输入。但是现在当我尝试使用 facebook 进行身份验证时,我收到了这个错误:

OpenSSL::SSL::SSLError

SSL_connect 返回=1 errno=0 state=SSLv3 读取服务器证书B:证书验证失败

我该如何解决?我解决了放入OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONEdevelopment.rb

4

2 回答 2

1

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

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

http://127.0.0.1

然后再试一次。如果它不起作用,http://localhost:3000请尝试从http://127.0.0.1:3000

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

于 2011-11-13T13:49:53.643 回答
1

当您的服务器在 http 协议上运行时会出现该错误。您需要在 APP_PATH 之前的 your_project/script/rails 中添加这段代码

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

更新您的 rails 脚本后,将 url 从更改http://127.0.0.1:3000https://127.0.0.1:3000

于 2011-11-14T16:02:31.163 回答