I'm attempting to cURL the Google Ads API with the following PHP code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 
'https://googleads.googleapis.com/v14/customers/[CUSTOMER_ID]:generateKeywordHistoricalMetrics');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [ 
'developer-token: [DEVELOPER_TOKEN',
'login-customer-id: [LOGIN_CUSTOMER_ID]',
'Authorization: Bearer [???????]',
'Accept: application/json'
 'Content-Type: application/json', ]);
curl_setopt($ch, CURLOPT_POSTFIELDS, 
'{"historicalMetricsOptions":{"yearMonthRange":{"start":{"month":"JUNE","year":2022},"end":{"month":"MAY","year":2023}}},"keywords":[""]}');
$response = curl_exec($ch);
curl_close($ch); 

And the response is:
{ "error": { "code": 401, "message": "Request had invalid authentication 
credentials. Expected OAuth 2 access token, login cookie or other valid 
authentication credential. See 
https://developers.google.com/identity/sign-in/web/devconsole-project.";, 
"status": "UNAUTHENTICATED" } } 

What I believe the issue to be is on the "*Authentication*" field. So far, 
I've put the following in that field(and failed each time):

   1. OAUTH 2 Client ID
   2. OAUTH 2 Client Secret
   3. OAUTH 2 Refresh Token, that works for another Google Ads project I've 
   made
   4. Developer token

So, I could appreciate any and all help, since I'm running out of ideas and 
don't know what to do.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/cbb0f360-e7c6-48f4-93ec-cc2281a7c86cn%40googlegroups.com.

Reply via email to