我对OAuth2相当陌生,而且我试图通过Google API与Omniauth和Google API客户端访问用户的Blogger帐户。我使用了以下内容:在使用Google Oauth2客户端访问API时Rails 3.2.3中的SSL错误
- 的Rails 3.2.3
- 的Ruby 1.9.3
- 的oauth2(0.8.0)
- omniauth(1.1.1)
- omniauth - 谷歌 - 的oauth2 (0.1.13)
- 谷歌-API的客户端(0.4.6)
当我第一次尝试用户与谷歌凭证认证,我已收到以下错误:
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
然而,当我添加了特定的路径,在初始化我的CA证书,该错误走:
provider :google_oauth2, ENV['GOOGLE_APP_ID'], ENV['GOOGLE_SECRET'], {
access_type: "offline",
approval_prompt: "",
scope: 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/blogger',
client_options: { ssl: { ca_file: cert_path } }
}
所以,现在我的用户可以与他们的谷歌凭据登录没问题。我现在看到的问题是,当我尝试使用访问令牌(在用户身份验证期间从Google接收)访问Blogger API时,我再次收到SSL错误。这是我用来访问API的代码:
token = auth.first.oauth_token.access_token # access token received during authentication
client = Google::APIClient.new
client.authorization.access_token = token
service = client.discovered_api('blogger', 'v3')
result = client.execute(
:api_method => service.blog_list.list,
:parameters => {},
:headers => {'Content-Type' => 'application/json'})
在线路service = client.discovered_api('blogger', 'v3')
我一直在敲打我的头靠在墙上,现在一个同时产生的误差,人有有任何想法吗?
关于如何在Linux机器上完成此任何想法? –