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:
- Is it possible to access the Google Ads API using a service account?
- 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.
According to a caveat on Google Ads API Service Accounts:
Regarding the 2 questions:
UPDATE:
Java is now supported.