Google Ads API - Refresh Token gets denied after 7 days

54 views
Skip to first unread message

Nicolas Gonzales

unread,
Jan 17, 2022, 4:10:36 AM1/17/22
to Google Ads API and AdWords API Forum
Hi Team

I am switching to the new Google Ads Api library and get some trouble with the Refresh Token.

I am using this code in php :

try {

$clickConversion = new ClickConversion([
'conversion_action' =>
ResourceNames::forConversionAction($customerId, $conversionActionId),
'gclid' => $gclid,
'conversion_value' => $conversionValue,
'conversion_date_time' => $conversionDateTime,
'currency_code' => 'EUR'
]);


$conversionUploadServiceClient = $googleAdsClient->getConversionUploadServiceClient();
/** @var UploadClickConversionsResponse $response */
$response = $conversionUploadServiceClient->uploadClickConversions(
$customerId,
[$clickConversion],
true
);


And using a google_ads_php.ini with the value of the refresh token.

It works during 7 days but after, I get the refresh token denied.

API Error:
GuzzleHttp\Exception\ClientException: Client error: `POST https://oauth2.googleapis.com/token` resulted in a `400 Bad Request` response:
{
"error": "invalid_grant",
"error_description": "Token has been expired or revoked."
}

"Auto-refresh token before it expires" is also ticked on the Google Developers Console.

So my question is :

How can I get a refresh token without using the Google Developers console ?
Or how can I get this refresh token automatically refreshed ?

Thanks for your help

Nicolas Gonzales

unread,
Jan 17, 2022, 4:20:41 AM1/17/22
to Google Ads API and AdWords API Forum
It look that I need to publish the API and send a video on Youtube.
A video explaining what I do exactly.

Am I right ?

Google Ads API Forum Advisor

unread,
Jan 17, 2022, 3:37:22 PM1/17/22
to ni...@nmg.digital, adwor...@googlegroups.com

Hi Nicolas,

Here's a list of reasons why a refresh token expires, a very common reason we encounter is a Google Cloud Platform project with an OAuth consent screen configured for an external user type and a publishing status of "Testing" is issued a refresh token expiring in 7 days. You may reach out to GCP support for assistance.

With that being said, note that you may encounter an need to authorize your GCP project app when publishing it according to this blog post -  Google Ads and AdWords APIs upgrading authorization scope to "sensitive".

Regards,

Google Logo
Aryeh Baker
Google Ads API Team
 

 



ref:_00D1U1174p._5004Q2VMYtL:ref
Reply all
Reply to author
Forward
0 new messages