我正在制作Ruby On Rails应用程序,并且尝试使用Google Plus API进行用户登录。为此,我正在使用OAuth帮助程序库Signet。我正在使用this代码作为带有Google API的Signet的示例。
这是我的代码:
require "signet/oauth_2/client"
require "google/api_client"
oathClient = Signet::OAuth2::Client.new(
:authorization_uri => "https://accounts.google.com/o/oauth2/auth",
:token_credential_uri => "https://accounts.google.com/o/oauth2/token",
:client_id => Rails.application.secrets.gapi_client_id,
:client_secret => Rails.application.secrets.gapi_client_secret,
:redirect_uri => Rails.application.secrets.gapi_redirect_uri,
:scope => "https://www.googleapis.com/auth/plus.login")
gapi_client = Google::APIClient.new(
:application_name => "Branches",
:application_version => "0.0.1")
oathClient.code = request.body.read
oathClient.fetch_access_token!#Error on this line
gapi_client.authorization = oathClient
在倒数第二行发生错误:
oathClient.fetch_access_token!
这是错误:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
我已经进行了一些研究,它的出现似乎是由于缺少证书信息引起的。但是,在处理Signet时,所显示的解决方案都无法解决此问题。
操作系统:Windows 8 x64RoR版本:4.1.1签章版本:0.5.1Google API客户端版本:0.6.2
与https://github.com/googleapis/google-api-ruby-client/issues/235有关的外观,其中解决方案是:
.pem
文件,请使用以下文件进行设置:export SSL_CERT_FILE=/path/to/custom/certificate/authority.pem