1
votes

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.

1
Where in the documentation does it say google Ads supports service accounts? - DaImTo
@DaImTo I could not find any info on this. Hence my first question: Is it possible to access the Google Ads API using a service account? - Nebu
Where is your documentation for Google ads api that you are looking at? - DaImTo
Hi - did you ever solve this? I am having an identical issue. - emvy03
@emvy03 Unfortunately no. For analytics (which did work with coldfusion btw) I made the switch to nodeJS to communicate with the google API.Main reason is better community support for these kind of problems. I use cfexecute to run the nodejs code from within coldfusion.I think this should also be possible for adwords but I haven't tried it yet. - Nebu

1 Answers

0
votes

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.


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