So I'm utilizing v23 of the googleads/google-ads-php.
I have all my credentials setup, and everything is working correctly.
I can confirm this by manually posting to the /token endpoint, and get an
access token. However, utilizing the SDK I get "{ "message": "Request is
missing required authentication credential. Expected OAuth 2 access token,
login cookie or other valid authentication credential. See
https:\/\/developers.google.com\/identity\/sign-in\/web\/devconsole-project.",
"code": 16, "status": "UNAUTHENTICATED", "details": [ { "@type":
"type.googleapis.com\/google.ads.googleads.v16.errors.GoogleAdsFailure",
"errors": [ { "errorCode": { "authenticationError":
"OAUTH_TOKEN_HEADER_INVALID" }, "message": "Oauth token HTTP header is
malformed." } ], "requestId": "k4fKAZ34qnUykl_MdjuIWw" } ] }"
It appears as though the access token is not being automatically generated.
Here is my code for getting the GoogleAdsClient object:
public static function getGoogleAdsClient(): GoogleAdsClient
{
$oAuth2Credential = (new OAuth2TokenBuilder())
->withClientId(config('google-ads.client_id'))
->withClientSecret(config('google-ads.client_secret'))
->withRefreshToken(config('google-ads.refresh_token'))
->build();
return (new GoogleAdsClientBuilder())
->withOAuth2Credential($oAuth2Credential)
->withDeveloperToken(config('google-ads.developer_token'))
->usingGapicV2Source(true)
->build();
}
And then my quick test:
$client = App\Libraries\Google\Ads::getGoogleAdsClient();
$googleAdsServiceClient = $client->getGoogleAdsServiceClient();
$query = 'SELECT campaign.id, campaign.name FROM campaign ORDER BY
campaign.id';
$stream = $googleAdsServiceClient->searchStream(
SearchGoogleAdsStreamRequest::build(config('google-ads.customer_id'),
$query)
);
foreach ($stream->iterateAllElements() as $googleAdsRow) {
printf(
"Campaign with ID %d and name '%s' was found.%s",
$googleAdsRow->getCampaign()->getId(),
$googleAdsRow->getCampaign()->getName(),
PHP_EOL
);
}
Any help would be appreciated because I'm tearing my hair out trying to get
this to work.
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/0f02c5b8-2f17-4043-9471-e4d015be32b8n%40googlegroups.com.