Search code examples
google-ads-apigoogle-workspaceservice-accounts

Accessing the Google Ads API using a service account without Google Workspace Domain?


I´d like to use the Google Ads API to programmatically retrieve ads data from my Google Ads account. I`d like to use a PHP script (Laravel command and the Google Ads API PHP client library) triggered by a cron-job to retrieve this data regularly. After reading the documentations a couple of times I still have a few questions:

Q1: My understanding is that for such "program to program" API access with no user involvement, I need to follow the service account authentication scenario. Is that right?

Q2: The service account documentation says that I have to have Google Workspace Domain with my company domain, email address, etc. My company website, email is hosted by another provider, do I really need to pay for the Google Workspace Domain, just to be able use the Google Ads API? Any alternative solutions?

Thanks for any suggestions on how to do this right. W.


Solution

  • Q1: No, that is not necessarily correct. You can use a regular Google account to run an "offline access" OAuth2 flow which will let you obtain a refresh token. The refresh token does not have a fixed lifetime and can be repeatedly exchanged for an access token until it is revoked. So your cron job will be able to authenticate just fine as long as you store the initial refresh token.

    Q2: Yes, in the realm of Google Ads, service account usage is only possible when used with domain-wide delegation inside a Google Workspace organization. But that shouldn't be an issue for your scenario as explained above.