Google Ads Api Developer Token Error - even though it is validated
I am developing an application which integrates with Google Ads and syncing Ad/Campaign etc. data into my servers. I am getting authorization related error when I try to request some data from Google Ads API. Here is the steps I have done by now:
- Applied to Google in terms of validating an OAuth application and scopes (Done, we got verification from Google and can ask for AdWords scope)
- Applied to Google Ads for getting a developer token and got it. (Basic Access)
- We are able to connect test accounts and successfully getting the response. But when we try it with real accounts we get the error below.
The code is also from the original Google Ads API example. I have tried with tons of different accounts but none of them seems to be working. When I try to obtain those data with same parameters from AdWords API instead of Google Ads API, it works. But Google AdWords PHP SDK is no longer maintained so I have to keep trying with Google Ads API. I share my code below:
{ $this->customerId = $customerId; $this->clientId = $clientId; $this->clientSecret = $clientSecret; $this->accessToken = $accessToken; $oAuth2Credential = (new OAuth2TokenBuilder()) ->withClientId($this->clientId) ->withClientSecret($this->clientSecret) ->withRefreshToken($this->accessToken) ->build(); $this->googleAdsClient = (new GoogleAdsClientBuilder()) ->withOAuth2Credential($oAuth2Credential) ->withDeveloperToken(env("GOOGLE_DEVELOPER_TOKEN")) ->withLoginCustomerId((int) $this->customerId) ->build(); } public function getCampaigns(): array{ try { $campaigns = []; $services = $this->googleAdsClient->getGoogleAdsServiceClient(); $results = $services->search($this->customerId, $this->campaignQuery(), ['pageSize' => self::PAGE_SIZE]); foreach ($results->iterateAllElements() as $row) { $campaigns[] = (new Campaign())->transform($row); } return $campaigns; } catch (GoogleAdsException $googleAdsException) { // TODO add error log return []; } }``` The error: ```Google\ApiCore\ApiException: { "message": "The caller does not have permission", "code": 7, "status": "PERMISSION_DENIED", "details": [ { "@type": 0, "data": "type.googleapis.com\/google.ads.googleads.v6.errors.GoogleAdsFailure" }, { "@type": 0, "data": [ { "errorCode": { "authorizationError": "DEVELOPER_TOKEN_PROHIBITED" }, "message": "Developer token is not allowed with project '691752477594'." } ] } ]}```