Thanks for the detailed response, but it sounds super confusing to me. Probably my fault, not yours.
I want the top left - middle accounts drop down (accounts under my MCC), so I guess I have to use https://developers.google.com/google-ads/api/docs/account-management/get-account-hierarchy, right? If I understand correctly the comments on that code, sending login_customer_id is not required but the API query should work OK if I send the login_customer_id (just like I'm doing in the other API queries that are working OK), right? I guess I don't need to send any Customer ID (it wouldnt make sense, because what I want to get is the list of Customer IDs under my MCC), but I still get the INVALID_CUSTOMER_ID error when I don't provide any. Also, do I have to use all the code on https://developers.google.com/google-ads/api/docs/account-management/get-account-hierarchy just to get a simple list of the Customer IDs (I don't care about hierarchy, I just want a simple list of IDs)? Seems a super complex code to get something very simple. All my other API queries are basically just the GAQL query, a couple of lines of Python code to process the info from the query and that's it. There is no simple solution like this to get a list of the Customer IDs? In case it helps this is a bigger version of the error that I get: *GoogleAdsException at /listing* *(<_SingleThreadedRendezvous of RPC that terminated with:* * status = StatusCode.INVALID_ARGUMENT* * details = "Request contains an invalid argument."* * debug_error_string = "{"created":"@1658904934.409000000","description":"Error received from peer ipv4:142.250.200.138:443 <http://142.250.200.138:443>","file":"src/core/lib/surface/call.cc","file_line":953,"grpc_message":"Request contains an invalid argument.","grpc_status":3}"* *>, <_SingleThreadedRendezvous of RPC that terminated with:* * status = StatusCode.INVALID_ARGUMENT* * details = "Request contains an invalid argument."* * debug_error_string = "{"created":"@1658904934.409000000","description":"Error received from peer ipv4:142.250.200.138:443 <http://142.250.200.138:443>","file":"src/core/lib/surface/call.cc","file_line":953,"grpc_message":"Request contains an invalid argument.","grpc_status":3}"* *>, errors {* * error_code {* * request_error: INVALID_CUSTOMER_ID* * }* * message: "Invalid customer ID \'\'."* *}* *request_id: "Vn8OyAiSL6hALb_i1O7feA"* *, 'Vn8OyAiSL6hALb_i1O7feA')* Thanks! On Tue, Jul 26, 2022 at 10:44 PM Google Ads API Forum Advisor <[email protected]> wrote: > Hi Miguel, > > Thank you for reaching out to Google Ads API with your question. To > explain how to access accounts in a visual way here are the *following > pointers:* > > Imagine that the same 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 > <https://developers.google.com/google-ads/api/docs/account-management/listing-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 > <https://developers.google.com/google-ads/api/docs/account-management/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 > <https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid> > and migration guide > <https://developers.google.com/google-ads/api/docs/migration/login-customer-id> > . > > Any account returned by List Accessible Accounts > <https://developers.google.com/google-ads/api/docs/account-management/listing-accounts> > when > using a specific refresh token doesn't need the login customer Id. > > Another property of those accounts returned by List Accessible Accounts > <https://developers.google.com/google-ads/api/docs/account-management/listing-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 > <https://developers.google.com/google-ads/api/docs/account-management/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 > <https://developers.google.com/google-ads/api/docs/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. > > - > https://oauth2.googleapis.com/tokeninfo?access_token=<INSERT_ACCESS_TOKEN> > ;; > > 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/v11/customers/{ > CID}/googleAds:searchStream > > > If the above doesn't help you, can you send us the log of all your refresh > token creation attempt listed above and the list of accounts returned when > following the List Accessible Accounts > <https://developers.google.com/google-ads/api/docs/account-management/listing-accounts> > guide? > > You may send the requested information via "Reply to author" or via > [email protected] > <https://mail.google.com/mail/u/0/?fs=1&tf=cm&source=mailto&[email protected]> > with > a link to this forum post added to the new thread. > > Regards, > > [image: Google Logo] > Aryeh > Google Ads API Team > > > > > > ref:_00D1U1174p._5004Q2d1gXF:ref > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog: https://googleadsdeveloper.blogspot.com/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "Google Ads API and AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/CAAuHZMbjvK3jWbC95rDJ9Ahx_YLrEwCy2A10j6%2Be0fei08vm7w%40mail.gmail.com.
