[英]AuthenticationError.OAUTH_TOKEN_INVALID
I am trying to access Google Adword's api through google's gem google-api-ads-ruby. 我正在尝试通过Google的gem google-api-ads-ruby访问Google Adword的api。 I was able to oauth in perfectly fine and grabbed the access token, refresh token, and id_token fine. 我能够很好地进行oauth,并获得了访问令牌,刷新令牌和id_token。 When I try to access the data it gives me the oauth token invalid error. 当我尝试访问数据时,它给了我oauth令牌无效错误。 I retrieved my access token and inputed it on this link and it returned me a valid result. 我检索了访问令牌并在此链接上输入了它,它返回了一个有效的结果。
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=[TOKEN] https://www.googleapis.com/oauth2/v1/tokeninfo?access_token= [令牌]
The code below is how I am trying to access the Report Definition Service. 下面的代码是我尝试访问报表定义服务的方式。
config = {
:authentication => {
:method => 'OAuth2',
:oauth2_client_id => @plugin.oauth_client_id,
:oauth2_client_secret => @plugin.oauth_client_secret,
:developer_token => @plugin.developer_token,
:client_customer_id => @plugin.client_customer_id,
:oauth2_token => {"access_token"=>ACCESSTOKEN,
"refresh_token"=>REFRESHTOKEN,
"issued_at"=>"2017-09-18T16:36:55.973-04:00",
"expires_in"=>3600,
"id_token"=>IDTOKEN,
:user_agent => 'Example'
},
:service => {
:environment => 'PRODUCTION'
}
}
api = AdwordsApi::Api.new(config)
report_def_srv = api.service(:ReportDefinitionService, :v201708)
report_type = "ACCOUNT_PERFORMANCE_REPORT"
This code below causes the error 下面的代码导致错误
fields = report_def_srv.get_report_fields(report_type)
Why do I keep getting the oauth token is invalid error when it hasn't expired yet? 为什么仍未过期的oauth令牌仍然是无效错误?
If the question is still actual.. 如果问题仍然存在。
Try to replace "expires_in"=>3600
field with "expires_at"=>"2017-09-18T17:36:55.973-04:00"
尝试将"expires_in"=>3600
字段替换为"expires_at"=>"2017-09-18T17:36:55.973-04:00"
It helped to resolve the similar issue in my case. 它有助于解决我的情况下的类似问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.