DEVELOPER_TOKEN_NOT_APPROVED by Google Ads API for PHP
I want to use the Google Ads API to access Google Ads reports. As a preliminary step, we want to use the GoogleCustomerServiceClient to retrieve customer information.
$MMC_ID = <My MMC 10 digits number>; $credentialsIniPath = app_path('resources/credentials/google/google_ads_php.ini'); $oAuth2Credential = (new OAuth2TokenBuilder()) ->fromFile($credentialsIniPath) ->build(); $googleAdsClient = (new GoogleAdsClientBuilder()) ->fromFile($credentialsIniPath) ->withOAuth2Credential($oAuth2Credential) ->build(); $customerServiceClient = $googleAdsClient->getCustomerServiceClient(); try { $customer = $customerServiceClient->getCustomer(ResourceNames::forCustomer($MMC_ID)); } catch(GoogleAdsException $e) { $this->error($e->getMessage()); }
But it returns an error
Fault ------- Status code: 7 Details: The caller does not have permission Failure: {"errors":[{"errorCode":{"authorizationError":"DEVELOPER_TOKEN_NOT_APPROVED"},"message":"The developer token is not approved. Non-approved developer tokens can only be used with test accounts."}]}
The account Oauth2 login that created MMC, MMC is a test account. In google_ads_php.ini
, clientId, clientSecret, refreshToken, and developerToken are already filled in. The refreshToken
has just been generated.
What should I check for in this one?
Thanks.