Posts under category Google

We are using Google ads API and we are getting the refresh_token and access_token from the oauthLibrary.

Now due to some reason (Majorly cause we are using JavaScript and there's no library for JavaScript officially from Google) we are relying on the REST API.

I want to fetch a list of Accounts attached to the the given access token. (no matter manager or not Manager) I just need the list.

I have tried the following endpoint

https://googleads.googleapis.com/v1/customers:listAccessibleCustomers

But I am getting 404 Not found in that, So I think it is discontinued, Any idea how I can fetch the list through REST_API.

I am using google-ads-api. My goal is to get impressions and clicks for specific campaign. These are the things I have done.

  1. created google service account
  2. Downloaded google-ads-library from github
  3. Added clientid , secretid, refresh token to my adsapi.ini file.

When I run the code it gives me error .

Google\ApiCore\ApiException { "message": "The caller does not have permission", "code": 7, "status": "PERMISSION_DENIED", "details": [ { "@type": "type.googleapis.com/google.ads.googleads.v9.errors.GoogleAdsFailure", "errors": [ { "errorCode": { "authorizationError": "USER_PERMISSION_DENIED" }, "message": "User doesn't have permission to access customer. Note: If you're accessing a client customer, the manager's customer id must be set in the 'login-customer-id' header. See https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid" } ], "requestId": "pKHgfIr99F5XApaPFBnrLQ" } ] }

my adsapi.ini

[GOOGLE_ADS] ; Required Google Ads properties. name = "Google Ads" developerToken = "*****-*******_*" ; Optional. Set a friendly application name identifier. userAgent = "Scraper" ; Optional additional AdWords API settings. ; endpoint = "https://adwords.google.com/" ; isPartialFailure = false ; Optional setting for utility usage tracking in the user agent in requests. ; Defaults to true. ; includeUtilitiesInUserAgent = true [ADWORDS_REPORTING] ; Optional reporting settings. ; isSkipReportHeader = false ; isSkipColumnHeader = false ; isSkipReportSummary = false ; isUseRawEnumValues = false [OAUTH2] ; Required OAuth2 credentials. Uncomment and fill in the values for the ; appropriate flow based on your use case. See the README for guidance: ; https://github.com/googleads/googleads-php-lib/blob/master/README.md#getting-started ; For installed application or web application flow. clientId = "**********************" clientSecret = "********************" refreshToken = "***********************"  For service account flow. ; jsonKeyFilePath = "INSERT_ABSOLUTE_PATH_TO_OAUTH2_JSON_KEY_FILE_HERE" ; scopes = "https://www.googleapis.com/auth/adwords" ; impersonatedEmail = "INSERT_EMAIL_OF_ACCOUNT_TO_IMPERSONATE_HERE" [SOAP] ; Optional SOAP settings. See SoapSettingsBuilder.php for more information. ; compressionLevel = <COMPRESSION_LEVEL> ; wsdlCache = <WSDL_CACHE> [PROXY] ; Optional proxy settings to be used by SOAP requests. ; host = "<HOST>" ; port = <PORT> ; user = "<USER>" ; password = "<PASSWORD>" [LOGGING] ; Optional logging settings. ; soapLogFilePath = "/soap.log" ; soapLogLevel = "INFO" ; reportDownloaderLogFilePath = "path/to/your/report-downloader.log" ; reportDownloaderLogLevel = "INFO" ; batchJobsUtilLogFilePath = "path/to/your/bjutil.log" ; batchJobsUtilLogLevel = "INFO" 

I can't seem to figure out why my code isn't returning ads with a specific labels and need help understanding where I went wrong with my code. I am iterating through the ad groups that have a specific label "AUTOENABLE" and then iterating through each ad with the same label but also checking on another script the URL endpoint.

  adCount: 0,   adsEnabled: 0,   adsDisabled: 0,   adsSetEnabled: [],   adsSetDisabled: [] }; function adsTest() {         var ag_iter = AdWordsApp.labels().withCondition("Name = AUTOENABLE").get();      if(ag_iter.totalNumEntities() < 1){     Logger.log("ERROR: No AUTOENABLE label found in AdGroup");     return;            // Iterating through all Ad groups to work individually     while (ag_iter.hasNext()) {     // Getting the ad group and printing it's name     var ag = ag_iter.next();     Logger.log(ag.getName())                   // Taking an iterator from all Ads inside Ad Group     var ad_iter = ag.ads().withCondition("LabelNames = AUTOENABLE").get();     if(ad_iter.totalNumEntities() < 1){     Logger.log("ERROR: No AUTOENABLE label found in Ads.");     return;   }     while(ad_iter.hasNext()){       var ad_iter = ads.next();       checkAd(ad);     }    }   }       report(); } function report(){     Logger.log(stats.adCount + " ads checked");     Logger.log(stats.adsEnabled + " ads are enabled");     Logger.log(stats.adsDisabled + " ads are disabled");     Logger.log((stats.adsSetDisabled.length + stats.adsSetEnabled.length) + " ads modified");     if(stats.adsSetEnabled.length > 0){       Logger.log("Changed to enabled:");       stats.adsSetEnabled.forEach(adLog);     }     if(stats.adsSetDisabled.length > 0){       Logger.log("\nChanged to disabled:");       stats.adsSetDisabled.forEach(adLog);     } }