有没有中文技术支持?我们遇到了invalid_grant的错误!

476 views
Skip to first unread message

hailong zhou

unread,
Jun 16, 2021, 3:10:01 AM6/16/21
to AdWords API and Google Ads API Forum
谷歌的技术人员你好:

我们在使用GoogleAds php客户端库时遇到了invalid_grant的错误,我们已经获取了refreshToken,并将clientId,clientSecret,developerToken,customerId,refreshToken都已经配置到了google_ads_php.ini中,google_ads_php.ini配置文件也已经存放在当前用户的home目录下。
我们在调用php客户端库中的例子程序GetCampaigns.php时,遇到了如下错误

[root@iZj6cjfcqhdx9dq7v068syZ BasicOperations]# php GetCampaigns.php --customerId=8989099376
PHP Fatal error:  Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://oauth2.googleapis.com/token` resulted in a `400 Bad Request` response:
{
  "error": "invalid_grant",
  "error_description": "Bad Request"
}
 in /home/gg/google-ads-php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /home/gg/google-ads-php/vendor/guzzlehttp/guzzle/src/Middleware.php(69): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), NULL, Array, NULL)
#1 /home/gg/google-ads-php/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /home/gg/google-ads-php/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)
#3 /home/gg/google-ads-php/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /home/gg/google-ads-php/vendor/guzzlehttp/pr in /home/gg/google-ads-php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113


之前也有求助过谷歌技术,但也没有解决问题,之前的回复有让我再继续核实一遍quickstart的内容,我也重新确认过,没有发现遗漏的地方,也有技术同学让我打开客户端库的Logging功能,打开后,我调用接口例子程序却没有任何日志记录下来。

上面的错误是发生在我们的生产账户中,我用自己的个人账户创建了一个test account,也是用同样的方法配置客户端库,最终可以成功调用接口,下面是我之前用test account调用成功的内容

[root@iZj6cjfcqhdx9dq7v068syZ BasicOperations]# php GetCampaigns.php --customerId=3602938739
Campaign with ID 13322273954 and name 'App promotion-App-1' was found.
[2021-06-16T15:03:18.234321+08:00] google-ads.INFO: Request made: Host: "googleads.googleapis.com", Method: "/google.ads.googleads.v6.services.GoogleAdsService/SearchStream", CustomerId: 3602938739, RequestId: "Vb4tDxILqxAYcOq41nZQ3g", IsFault: 0, FaultMessage: "None"

所以这也是一个很大的疑问,为什么我们的test account可以成功调用接口,而production account却不能调用成功呢?用得还是同样的配置方法,到底是哪里不对呢?

希望能有技术支持可以帮忙解决我们的问题,多谢了!

Google Ads API Forum Advisor

unread,
Jun 17, 2021, 12:18:21 PM6/17/21
to pipe...@gmail.com, adwor...@googlegroups.com
Hello,

Thanks for your patience. Please note that our channel can only provide English support.

Can you please provide us with the complete request and response logs from the successful test account call? This will let us look more closely at the issue.

Regards,
Matt
Google Ads API Team

Google Logo
Matt
Google Ads API Team
 


ref:_00D1U1174p._5004Q2Iw6S1:ref

yushan mu

unread,
Jun 18, 2021, 12:46:57 PM6/18/21
to AdWords API and Google Ads API Forum

你好,能留一个微信或其他的联系方式么。我使用java语言也无法正常执行GetCampaigns 能否帮我看看在基础配置中我哪里是否有问题

Google Ads API Forum Advisor

unread,
Jun 21, 2021, 2:29:35 PM6/21/21
to muyush...@gmail.com, adwor...@googlegroups.com
Hello,

Unfortunately, our team can only provide email support. If you can provide us with a summary of the current issue, we will be able to better assist. If you suspect that your issue pertains specifically to the Java client library, you can reach out to the Java client library owners here, on their GitHub page.

lee

unread,
Jun 25, 2021, 5:01:54 AM6/25/21
to AdWords API and Google Ads API Forum
请问你们解决了吗?我们也是php,然后也遇到了类似的问题,有无联系方式

在2021年6月16日星期三 UTC+8 下午3:10:01<pipe...@gmail.com> 写道:

Google Ads API Forum Advisor

unread,
Jun 28, 2021, 3:21:49 AM6/28/21
to aichiten...@gmail.com, adwor...@googlegroups.com
Hi Lee,

Thank you for commenting on this forum post. Allow me to provide support to your concern.

Before I proceed with your concern, I would like to inform you first that our team can only provide support in English so we will appreciate if you can reply on this language as well.

To give you an overview first about the invalid_grant error, this signifies that the access or refresh token being passed in your request is incorrect or invalid. Please note that the email address used to generate those credentials should have the appropriate access to the production account that you're trying to make an API request. The other reason is that, your refresh token is already expired.

With this, if you encounter the said error, you may follow the guides below again and retry the API request:
https://developers.google.com/google-ads/api/docs/first-call/oauth-cloud-project
https://developers.google.com/google-ads/api/docs/first-call/oauth-client-library
https://developers.google.com/google-ads/api/docs/first-call/refresh-token

If the issue persists, you can provide the email address / user account used to generate Oauth2 credential and the complete request and response logs with request ID generated on your end to further investigate. You can provide it via Reply privately to author option.

Regards,
Google Logo
Ernie John Blanca Tacata
Google Ads API Team
 


ref:_00D1U1174p._5004Q2Iw6S1:ref
Message has been deleted

Google Ads API Forum Advisor

unread,
Jun 29, 2021, 5:44:48 AM6/29/21
to xia744...@gmail.com, adwor...@googlegroups.com
Hi,

Please note that our team can only provide support in English. If you will send your replies in different language, then we will use Google translate to check your concern.

Moving forward, you are correct that the issue is related to authorization / authentication of API request and specifically when the access or refresh token being passed in your request is incorrect or invalid. Also, the email address used to generate those credentials doesn't have appropriate access to the production account that you're trying to make an API request. Lastly, your refresh token is already expired.

The appropriately action to do after receiving this error is to follow the instruction below:
As for the provided demo library, it will be more helpful if you can provide the email address / user account used to generate Oauth2 credential and the complete request and response logs with request ID generated on your end to further investigate.

You can share it via Reply privately to author option.
Reply all
Reply to author
Forward
0 new messages