Google adwords customers API is not returning customers list?
I have this following code to fetch all list of ads clients comes under a Ads manager account, I am using manager credentials to get list of clients.
public Customer[] GetAllManagerClientsList(string currentUserEmail, string authorizationCode) { string baseURL = _configuration.GetValue<string>("URL:SiteURL"); var currentUser = _userRepository.GetIntegratedAppsDetailByEmail(currentUserEmail); AdsOAuthProviderForApplications oAuth2Provider = (user.OAuthProvider as AdsOAuthProviderForApplications); oAuth2Provider.Config.OAuth2RedirectUri = baseURL + "/google-auth-callback"; oAuth2Provider.FetchAccessAndRefreshTokens(authorizationCode); //Get customerID user.Config.OAuth2AccessToken = oAuth2Provider.Config.OAuth2AccessToken; user.Config.OAuth2RefreshToken = oAuth2Provider.Config.OAuth2RefreshToken; CustomerService customerService = (CustomerService)user.GetService(AdWordsService.v201809.CustomerService); var customersList = customerService.getCustomers(); var ClientCustomers = customersList != null && customersList.Length > 0 ? customersList.Where(c => c.canManageClients == false).ToList() : null; if (ClientCustomers.Count() > 0) { return ClientCustomers.ToArray(); } else { return null; } }
Faruk What is your question? What are you seeing? It's not really clear what the issue is.
Edit: You tagged this with Google-Ads-API, that's the old API. My code below is for the new Google Ads API but might point you in the right direction if you need to use the older one.
You're using the correct service, just not the correct method. You need to use the list_accessible_customers() method:
def get_mccs_and_direct_admin_only_accounts(client): customer_service = client.get_service('CustomerService', version='v6') try: accessible_customers = customer_service.list_accessible_customers() resource_names = accessible_customers.resource_names for resource_name in resource_names: print('Customer resource name: "%s"' % resource_name)There is an ad manager account as Ads Manager , and that manager has clients who holds on ad account of google ads, I am integrating google ads API in my project ,So I am hitting google API to get All customers/Clients list which comes under me, But Api is not returning me my clients. this is google service provided by google iteself. CustomerService customerService =(CustomerService)user.GetService(AdWordsService.v201809.CustomerService); var customersList = customerService.getCustomers();
I've updated my answer given you provided a question/clarification.