AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED thrown at random

117 views
Skip to first unread message

Agusti Bau

unread,
Nov 28, 2017, 2:22:30 AM11/28/17
to AdWords API Forum
Hello guys,

I'm developing an integration with you guys, basically the functionality I want to achieve is that my clients use my tool to add users to their remarketing lists.

To do that I've implemented the oauth flow and registered for the google api.

I'm storing the clientId, clientSecret and Adwords developer token (test for now), in my server, and then storing refresh tokens for each user who go through the oauth flow.

When i need some data from Google Apis, I run the code at the end of the post and then get the services needed.

Most of the times I get correct responses, but some times I get AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED, like this one:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<ns2:ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201710" xmlns:ns2="https://adwords.google.com/api/adwords/rm/v201710">
<requestId>00055ef91cc02b680a81118635009f51</requestId>
<serviceName>AdwordsUserListService</serviceName>
<methodName>get</methodName>
<operations>1</operations>
<responseTime>48</responseTime>
</ns2:ResponseHeader>
</soap:Header>
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>[AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED @ ; trigger:'&lt;null&gt;']</faultstring>
<detail>
<ns2:ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201710" xmlns:ns2="https://adwords.google.com/api/adwords/rm/v201710">
<message>[AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED @ ; trigger:'&lt;null&gt;']</message>
<ApplicationException.Type>ApiException</ApplicationException.Type>
<errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AuthenticationError">
<fieldPath/>
<trigger>&lt;null&gt;</trigger>
<errorString>AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED</errorString>
<ApiError.Type>AuthenticationError</ApiError.Type>
<reason>CLIENT_CUSTOMER_ID_IS_REQUIRED</reason>
</errors>
</ns2:ApiExceptionFault>
</detail>
</soap:Fault>
</soap:Body>


private AdWordsSession initSession(String refreshToken) throws ValidationException, OAuthException {
Credential credential = new OfflineCredentials.Builder()
.forApi(OfflineCredentials.Api.ADWORDS)
.withClientSecrets(clientId, clientSecret)
.withRefreshToken(refreshToken)

.build()
.generateCredential();

// Create a new AdWordsSession without using a properties file.
return new AdWordsSession.Builder()
.withDeveloperToken(developerToken)
.withOAuth2Credential(credential)
.build();
}








Any help will be appreciated.

Vincent Racaza (AdWords API Team)

unread,
Nov 28, 2017, 3:54:50 AM11/28/17
to AdWords API Forum
Hi Agusti,

The CLIENT_CUSTOMER_ID_IS_REQUIRED error means that you did not specify a clientCustomerId in your request. Based on your code, it seems that you are not using the property file in setting the OAuth2 credentials. With this, please set the clientCustomerId this way:

Credential oAuth2Credential = new OfflineCredentials.Builder()
       
.forApi(Api.ADWORDS)
       
.withClientSecrets("XXXXXXX", "XXXXXXX")
       
.withRefreshToken("XXXXXXXXXXXX")
       
.build()
       
.generateCredential();

// Construct an AdWordsSession.
AdWordsSession session = new AdWordsSession.Builder()
       
.withDeveloperToken("XXXXXXXXXXXXX")
       
.withClientCustomerId("XXX-XXX-XXXX")
       
.withOAuth2Credential(oAuth2Credential)
       
.build();

Let me know if this helps.

Thanks,
Vincent
AdWords API Team

Agusti Bau

unread,
Nov 28, 2017, 5:57:56 AM11/28/17
to AdWords API Forum
Hello Vincent,
Most of the calls succeed... the client customer id relates to the final user right? Do I need my users to input it by hand?

Vincent Racaza (AdWords API Team)

unread,
Nov 28, 2017, 10:12:49 PM11/28/17
to AdWords API Forum
Hi Agusti,

The clientCustomerId is the customer ID of your target AdWords account which is usually, in the form of 123-456-7890. According to this guide, the clientCustomerId is required for all requests except CustomerService and ReportDefinitionService (specifically if you are running the reports in parallel).

There's a possibility that your calls succeeded without clientCustomerId when you were using the said two services. However, with the other API services, it will always return that specific error if you'll not specify a clientCustomerId.

Our recommended approach is to set the clientCustomerId and other OAuth2 credentials in the property file. This way, you don't have to set these fields in your code just like this example specifically on this line.
Reply all
Reply to author
Forward
0 new messages