Manager Account ID

496 views
Skip to first unread message

barbara jaymon

unread,
Nov 22, 2022, 9:40:02 AM11/22/22
to Google Ads API and AdWords API Forum
Hello, suppose I want to login to Google Ads via OAuth2 API and I'm an account manager, how do I get my Account ID after logging in? Is there a REST API for that? 

I tried using the Method: customers.listAccessibleCustomers but it gave me a list of account ids without much details, not sure how to pick my id from the list. Thanks in advance!

Kind regards,

Google Ads API Forum Advisor

unread,
Nov 22, 2022, 2:52:23 PM11/22/22
to barbs...@gmail.com, adwor...@googlegroups.com

Hi Barbara,
 

Thanks for reaching out to the Google Ads API team. I hope you are doing well today.
 

To explain how to access accounts in a visual way here are the following pointers:
 

The Google account that generated the refresh token used to access the API was to access an account in the Ads UI. They will see all the the accounts that List Accessible Accounts returns in the top right drop down list when you click the circle representation of the user in the UI. These are accounts the user has direct access to. If an account in that list is an MCC with child accounts attached, then to see the child accounts you would select that MCC in the top right of the UI and then the child accounts are accessible in the top left - middle accounts drop down list box in the UI. These are the same accounts that Get Account Hierarchy shows. 


To access accounts that are in the top left - middle accounts drop down list box via the API you would put the selected account in the top right list in the UI as login customer Id, and you would put the selected account in the top left - middle accounts drop down list box as the operating customer.
 

Here are a few more useful pointers:


Here's our login customer Id guide and migration guide.
 

Any account returned by List Accessible Accounts when using a specific refresh token doesn't need the login customer Id.
 

Another property of those accounts returned by List Accessible Accounts is they are the only accounts that can be a login customer Id for the specific refresh token making the API call.


Any account returned by Get Account Hierarchy when you you don't specify manager ID and login customer ID can be accessed by your refresh token you used to make the API call.
 

Debugging API calls:
 

To generate a refresh token and be able to detect who generated it you can follow our OAuth Playground guide and add another scope -https://www.googleapis.com/auth/userinfo.email.

 If that works, then generate an access token from that refresh token in a Bash Terminal.

  • curl --data "refresh_token=<INSERT_REFRESH_TOKEN>&client_id=<INSERT_YOUR_CLIENT_ID_FROM_API_CONSOLE>&client_secret=<INSERT_CLIENT_SECRET>&grant_type=refresh_token" -X POST "https://oauth2.googleapis.com/token"

Now, we want to check the data on the access token to make sure everything on the access token is working as expected. Put this in your browser with the access token inserted that you got back.

If that works, then let's try a request from the command line:

  • curl --header "Authorization: Bearer <INSERT_ACCESS_TOKEN>" --header "developer-token: <INSERT_DEV_TOKEN>" --header "login-customer-id: {LGNCID}" --data "{ 'query': 'SELECT campaign.id FROM campaign LIMIT 1' }" -X POST -H "Content-Type: application/json" https://googleads.googleapis.com/v12/customers/{CID}/googleAds:searchStream

 

I hope this helps.

 

Let us know if you have further questions.

 

Regards,

Google Logo
Darwin
Google Ads API Team
 


ref:_00D1U1174p._5004Q2gRdut:ref
Reply all
Reply to author
Forward
0 new messages