I am trying to connect to the google ads api using a service account. For analytics there is a good article named Hello Analytics API: Java quickstart for service accounts which explains how to set this up. For Google ads I can't find any documentation online.

So my two questions are:

  1. Is it possible to access the Google Ads API using a service account?
  2. If so, is there something like a Hello Ads API: Java quickstart for service accounts page with information on how to connect to the api with a service account?

UPDATE 2/10

I succeeded in passing the authentication fase. I do get an error when trying to fetch data from the API.

curl.exe --request POST "https://googleads.googleapis.com/v5/customers/******/googleAds:searchStream" --header "Content-Type: application/json"  --header "Authorization: Bearer ******"  --header "developer-token: ******"  --data "{'query': 'SELECT * FROM campaign WHERE segments.date DURING YESTERDAY'}" [{   "error": {     "code": 401,     "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.",     "status": "UNAUTHENTICATED",     "details": [       {         "@type": "type.googleapis.com/google.ads.googleads.v5.errors.GoogleAdsFailure",         "errors": [           {             "errorCode": {               "authenticationError": "NOT_ADS_USER"             },             "message": "User in the cookie is not a valid Ads user."           }         ]       }     ]   } } ] 

The google docs say this error is because the account is not associated with an google ads account (https://developers.google.com/google-ads/api/docs/best-practices/common-errors#not_ads_user). The request are being processed by the api, I know this because the request are counted in the google ads api console as errors.

In the Credentials compatible with this API for the google ads Api my service account is listed. I am a little puzzled by the error. The service-account is associated with the google ads account as far as I could tell.

Tag:google-ads-api, java, google-api, coldfusion-2016

4 comments.

  1. Donnald Cucharo

    According to a caveat on Google Ads API Service Accounts:

    Note: Not all our client libraries currently support service accounts. Service accounts can still be used if you implement the OAuth2 service account flow yourself.


    Regarding the 2 questions:

    Yes, it is possible to access Ads API using service accounts (only with Python and .NET) Google Ads API recommends Service Account flow however, it is not yet supported in Java.

    UPDATE:

    Java is now supported.

    1. Linda Lawton - DaImTo

      Both of your links result in Service Unavailable do you have an valid links? Google api java client supports service accounts, if Google Ads api does then it will work. On the other hand not all Google apis support service accounts so im not sure where your getting your quote from.

    2. Donnald Cucharo

      The quote is from Google Ads API doc > OAuth > Service Accounts which is the link I've provided. I asked other people and tried accessing the link using a different network and I'm able to access the link.

    3. Sarp Başaraner

      Java seems to be supported now.

Add a new comment.