突然(可能是 gem 更新?)调用 Google api 停止工作了。
我已经能够检索 Gmail 线程,但现在不能了。
到目前为止我所拥有的:
我能够检索刷新令牌以进行离线访问。所以我存储了刷新和访问令牌。伟大的。
现在我想检索个人资料信息。这就是我所做的(请注意,这曾经工作得很好!)
我将在下面的每一行后面添加一个 put 来向您展示我们得到的内容......
module AuthHelper
require 'google/api_client/client_secrets'
...
client = Signet::OAuth2::Client.new(access_token: user.gmail_access_token)
service = Google::Apis::GmailV1::GmailService.new
service.authorization = client
service.get_user_profile('me') # retrieve threads
...
end
让我打印我得到的回复:
CLIENT : --- !ruby/object:Signet::OAuth2::Client
authorization_uri:
token_credential_uri:
client_id:
client_secret:
code:
expires_at:
expires_in:
issued_at:
issuer:
password:
principal:
redirect_uri:
scope:
state:
username:
expiry: 60
extension_parameters: {}
additional_parameters: {}
access_token: ya29.Ci8QA3K_mLh1vB_55bSnGVB66yLwzkxClM8yCI5qmmZo6n0JzjVNA7Q6EAOm3qQeGw
SERVICE : --- !ruby/object:Google::Apis::GmailV1::GmailService
root_url: https://www.googleapis.com/
base_path: gmail/v1/users/
upload_path: upload/gmail/v1/users/
batch_path: batch
client_options: !ruby/struct:Google::Apis::ClientOptions
application_name: unknown
application_version: 0.0.0
proxy_url:
use_net_http: false
request_options: !ruby/struct:Google::Apis::RequestOptions
authorization:
retries: 0
header:
timeout_sec:
open_timeout_sec: 20
SERVICE.authorization : --- !ruby/object:Signet::OAuth2::Client
authorization_uri:
token_credential_uri:
client_id:
client_secret:
code:
expires_at:
expires_in:
issued_at:
issuer:
password:
principal:
redirect_uri:
scope:
state:
username:
expiry: 60
extension_parameters: {}
additional_parameters: {}
access_token: ya29.Ci8QA3K_mLh1vB_55bSnGVB66yLwzkxClM8yCI5qmmZo6n0JzjVNA7Q6EAOm3qQeGw
{"message":"Sending HTTP get https://www.googleapis.com/gmail/v1/users/me/profile?","@timestamp":"2016-06-28T19:52:38.974-07:00","@version":"1","severity":"DEBUG","host":"ben.local"}
{"message":"Caught error Missing token endpoint URI.","@timestamp":"2016-06-28T19:52:38.976-07:00","@version":"1","severity":"DEBUG","host":"ben.local"}
{"message":"Error - #\u003cArgumentError: Missing token endpoint URI.\u003e\n","@timestamp":"2016-06-28T19:52:38.977-07:00","@version":"1","severity":"DEBUG","host":"ben.local"}
GOT EXCPETION: Missing token endpoint URI.
我不应该看到这个:“缺少令牌端点 URI”。当您使用 access_token 时,它应该处理授权,对吧?正如我所说,这以前不是问题。
虽然我认为不需要,但我添加了端点 URI 'https://accounts.google.com/o/oauth2/auth' 来自 client_secret.json 并获取授权失败。
我错过了什么? :)