Anirudh
Anirudh

Reputation: 3358

How to get Authenticated user's Google Ad Account ID using Google Ads API v0 using a REST API?

I have been trying to figure out after referring to their official documentation (Google Ads API Document) which is not clear enough

Here is what I have tried till now.

I have created an app where users can log in with their Google Ad words account. I need to fetch their Ad performance reports via REST API.

To make an API request to fetch performance reports, we need the Google Ad Words Account ID of the authenticated user. Currently, as I am testing it with my personal account, I can login to my Ad words Console and get the Ad Words Account ID. But, how do I fetch the Ad Words Account ID dynamically for other users who authenticate via my App?

I tried looking for a way in their official documentation. But I couldn't figure out.

Could someone help me with the REST API URL which needs to be called to fetch the authenticated user's Ad words Account ID.

Upvotes: 3

Views: 1580

Answers (2)

Brian from state farm
Brian from state farm

Reputation: 2896

According to the documentation here Account overview, you need to list the customers to get the ID. For each user that logs in as long as they do not have access to multiple accounts you should get a single customer and their ID.

CustomerService

CustomerService provides information about your accounts. It has a getCustomers() method that takes no arguments and returns a list of Customer objects containing fields such as customerId, currencyCode, and dateTimeZone. CustomerService also has a mutate() method that can be used to update various attributes of a customer, including the autoTaggingEnabled and conversionTrackingSetting fields.

If no clientCustomerId is specified in a request, the response will contain multiple entries if more than one account is directly accessible by the authenticated account.

Upvotes: 0

Bsquare ℬℬ
Bsquare ℬℬ

Reputation: 4487

In addition to previous answer, I guess this is what you are looking for: https://developers.google.com/adwords/api/docs/guides/first-api-call#create_test_accounts

It explains how to setup Google Ad Words API and get your ID.

Upvotes: 0

Related Questions