ManagedCustomerService gives An AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED Error

349 views
Skip to first unread message

Aswini

unread,
Apr 9, 2015, 2:59:48 AM4/9/15
to adwor...@googlegroups.com
Hi 

I got CLIENT_CUSTOMER_ID_IS_REQUIRED Error  Error ManagedCustomerService in .net Client library. please check the code below 

            ManagedCustomerService managedCustomerService = (ManagedCustomerService)user.GetService(
                          AdWordsService.v201409.ManagedCustomerService);

            // Create selector.
            Selector selector = new Selector();          
            selector.fields = new String[] { "CustomerId", "Name" };
            try
            {
                ManagedCustomerPage page = managedCustomerService.get(selector); 
             }


Marcin Gdak

unread,
Apr 9, 2015, 4:42:42 AM4/9/15
to adwor...@googlegroups.com
Hi Aswini,

You must have CustomerId before the request to ManagedCustomerService. CustomerId you can charge from Customer Service.


Aswini

unread,
Apr 9, 2015, 5:53:06 AM4/9/15
to adwor...@googlegroups.com
HI Marcin,

Actually i need to download Client id from MCC account. Is there any way to download ?? version v201406 using of ManagedCustomerService i downloaded Client Id's. after migrating into v201409 i am facing these issue. Is there any way to download all client Id's from MCC account ??

Thanet Knack Praneenararat (AdWords API Team)

unread,
Apr 9, 2015, 7:21:45 AM4/9/15
to adwor...@googlegroups.com
Hi Aswini,

Have you set your clientCustomerId in App.config?

Cheers,
Thanet

Aswini

unread,
Apr 9, 2015, 7:36:53 AM4/9/15
to adwor...@googlegroups.com
Could you please try to understand issue. Test Mcc account have multiple clients(around 60 ), We can't take each and every Client Id from Mcc account and store into Local DB. Solving this manual process we did automated with following code which was version v201406 

Code: 

ManagedCustomerService managedCustomerService = (ManagedCustomerService)user.GetService(AdWordsService.v201409.ManagedCustomerService);
            managedCustomerService.RequestHeader.clientCustomerId = null;

            // Create selector.
            Selector selector = new Selector();
            selector.fields = new String[] { "Login", "CustomerId", "Name" };
            try
            {
                ManagedCustomerPage page = managedCustomerService.get(selector);

                if (page.entries != null)
                {
                    // Create map from customerId to customer node.
                    //Dictionary<long, ManagedCustomerTreeNode> customerIdToCustomerNode =
                    //new Dictionary<long, ManagedCustomerTreeNode>();

                    // Create account tree nodes for each customer.
                    foreach (ManagedCustomer customer in page.entries)
                    {
                        dtClients.Rows.Add(customer.customerId.ToString(), customer.name.ToString(), "");//
                        ///customer.login.ToString()); 
                        ///The login field can no longer be used in the ManagedCustomer class within the ManagedCustomerService.
                        ///See this blog post(http://googleadsdeveloper.blogspot.com/2014/09/login-field-sunsetting-in-adwords-api.html) for more information.
                        ///
                    }
                }
                dbConnection.Open();
                if (dtClients.Rows.Count != 0)
                {
                    genUtilities.eraseAdWords("Clients");
                    using (SqlBulkCopy s = new SqlBulkCopy(dbConnection))///inserting campaigns to DB
                    {
                        s.DestinationTableName = "Clients";
                        foreach (var column in dtClients.Columns)
                            s.ColumnMappings.Add(column.ToString(), column.ToString());
                        s.WriteToServer(dtClients);
                    }
                }

            }
            catch (AdWordsApiException ex)
            {
                ApiException innerException = ex.ApiException as ApiException;
                LogFile("Failed to download Client Id's from google server ", "",
                  innerException.errors.ToString(), innerException.message.ToString());
            }
            catch (Exception ex)
            {
                LogFile("Failed to download Client Id's from google server ", "", ex.Data.ToString(), ex.InnerException.Data.ToString());

            }
            finally
            {
                if (dbConnection.State == ConnectionState.Open)
                {
                    dbConnection.Close();
                }
            }
        }
This Code is perfectly working and i am able to store in local Database.

After Migration Into version v201409

        1    (user.Config as AdWordsAppConfig).ClientCustomerId = "442-017-1224";
        2   // Get the ManagedCustomerService.
        3    ManagedCustomerService managedCustomerService = (ManagedCustomerService)user.GetService(AdWordsService.v201409.ManagedCustomerService);

        4    // Create selector.
        5    Selector selector = new Selector();          
        6    selector.fields = new String[] { "CustomerId", "Name" };
        7    try
        8   {
        9        ManagedCustomerPage page = managedCustomerService.get(selector);

        10       if (page.entries != null)
        11        {
        12            // Create map from customerId to customer node.
        13           //Dictionary<long, ManagedCustomerTreeNode> customerIdToCustomerNode =
        14            //new Dictionary<long, ManagedCustomerTreeNode>();

        15            // Create account tree nodes for each customer.
        16           foreach (ManagedCustomer customer in page.entries)
        17            {
                        dtClients.Rows.Add(customer.customerId.ToString(), customer.name.ToString(), "");//
                        ///customer.login.ToString()); 
                        ///The login field can no longer be used in the ManagedCustomer class within the ManagedCustomerService.
                        ///See this blog post(http://googleadsdeveloper.blogspot.com/2014/09/login-field-sunsetting-in-adwords-api.html) for more information.
                        ///
                    }
                }
                dbConnection.Open();
                if (dtClients.Rows.Count != 0)
                {
                    genUtilities.eraseAdWords("Clients");
                    using (SqlBulkCopy s = new SqlBulkCopy(dbConnection))///inserting campaigns to DB
                    {
                        s.DestinationTableName = "Clients";
                        foreach (var column in dtClients.Columns)
                            s.ColumnMappings.Add(column.ToString(), column.ToString());
                        s.WriteToServer(dtClients);
                    }
                }

            }
            catch (AdWordsApiException ex)
            {
                ApiException innerException = ex.ApiException as ApiException;
                LogFile("Failed to download Client Id's from google server ", "",
                  innerException.errors.ToString(), innerException.message.ToString());
            }
            catch (Exception ex)
            {
                LogFile("Failed to download Client Id's from google server ", "", ex.Data.ToString(), ex.InnerException.Data.ToString());

            }
            finally
            {
                if (dbConnection.State == ConnectionState.Open)
                {
                    dbConnection.Close();
                }
            }


If i will comment 1st line of the code its throwing Error : CLIENT_CUSTOMER_ID_IS_REQUIRED Error, Other wise i am downloading only the assigned Client Id details. Is there any way to download all Client Ids from Mcc account ??? 

Thanet Knack Praneenararat (AdWords API Team)

unread,
Apr 9, 2015, 11:35:44 AM4/9/15
to adwor...@googlegroups.com
Hi,

Sorry for my brief response. I did understand your situation but my response seemed not. :-)
Actually, I intended to ask if you have tried filling in the clientCustomerId of your MCC account in App.config?

If you do so and all child accounts are really linked to your MCC account, they should get populated.
You don't need to specify your child accounts' customer ID one by one.

Note that this will return a ManagedCustomerLink for the MCC itself, plus both AdWords and MCC accounts under the MCC. 
You can differentiate between MCC and AdWords accounts using the canManageClients field.

You may find this example similar to what you would like to do.

Basically, if you don't specify any CID, the code will not work.

Cheers,
Thanet

Aswini

unread,
Apr 15, 2015, 2:41:23 AM4/15/15
to adwor...@googlegroups.com
Thanks!! Praneenararat. Its working now actually  we confused about Customer Id and Client Customer Id(Child accounts)

MWA

unread,
Apr 20, 2015, 9:29:19 AM4/20/15
to adwor...@googlegroups.com
Hi
I have a same problem in and I'm using PHP. I cannot figure out the problem.

My code is same as here
https://github.com/googleads/googleads-php-lib/blob/master/examples/AdWords/v201502/AccountManagement/GetAccountHierarchy.php

$user
= new AdWordsUser();
$user
->LogDefaults();

// Get the CampaignService.            
$managedCustomerService
= $user->GetService('ManagedCustomerService', ADWORDS_LATEST_VERSION);

// Create selector.
$selector
= new Selector();
$selector
->fields = array('CustomerId', 'Name');


$graph
= $managedCustomerService->get($selector);

print_r
($graph)

Still same error
[AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED @ ; trigger:'

I have agency MCC account and I and checking to my client has accepted my invitation or not. If there is any better way to do this please let me know.

Thanks.

Thanet Knack Praneenararat (AdWords API Team)

unread,
Apr 21, 2015, 2:00:35 AM4/21/15
to adwor...@googlegroups.com
Hi,

Have you set your clientCustomerId (your MCC account ID) in App.config?

Cheers,
Thanet, AdWords API Team

MWA

unread,
Apr 21, 2015, 4:06:17 AM4/21/15
to adwor...@googlegroups.com
I am using PHP client library. I assume you are talking about auth.ini and section

; Uncomment to make requests against a client account.
; clientId = "INSERT_CLIENT_CUSTOMER_ID_HERE"

I have a question do I have to change it every time I download adwords data of a client? And this is my client's customerId not mine agency ID.
I have some client and I download their reports and also check that either they have accepted request or not.

Please guide me through this.


On Thursday, April 9, 2015 at 11:59:48 AM UTC+5, Aswini wrote:

Thanet Knack Praneenararat (AdWords API Team)

unread,
Apr 21, 2015, 4:25:55 AM4/21/15
to adwor...@googlegroups.com
Hi,

Sorry for my wrong words.
I mistakenly thought you use .NET.
And yes, the clientCustomerId I mentioned is in the auth.ini file (line 13).

Regarding you another question, as I pointed out above, you can fill in your MCC account ID instead of each child account's customer ID.

Provided that your clients' accounts are already linked as your child accounts, you should be able to download reports related to those accounts.
You don't need to specify your child accounts' customer ID one by one.

Cheers,
Thanet, AdWords API Team

MWA

unread,
Apr 21, 2015, 4:59:04 AM4/21/15
to adwor...@googlegroups.com
Thank you very much it worked. After I set clientCustomerId to my MCC Id in auth.ini



On Thursday, April 9, 2015 at 11:59:48 AM UTC+5, Aswini wrote:
Reply all
Reply to author
Forward
0 new messages