CustomerService, getCustomers: QuotaCheckError.INVALID_TOKEN_HEADER

54 views
Skip to first unread message

Giacomo Furlan

unread,
Jun 27, 2018, 4:59:53 PM6/27/18
to AdWords API and Google Ads API Forum
Hello!

I'm trying to get the AdWords API work on my service's integration. I'm trying to use the CustomerService to get the list of customers associated of the oauth-authenticated account.

What I've done so far:
1. I've went to the Google API dashboard and enabled the Google Ads API from the library
2. I've created an API key (unrestricted for now) from the credentials page
3. I've created an OAuth 2.0 clients ID

Then I configured an API session with the following information:

1. the (unexpired (tested)) access token
2. the refresh token
3. the client id (see previous point 3)
4. the client secret (see previous point 3)
5. the developer key (see previous point 2)

Now trying to call the getCustomers SOAP call, it throws an exception (QuotaCheckError.INVALID_TOKEN_HEADER) triggered by the API key.

My call (stripped out sensible information):

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://adwords.google.com/api/adwords/mcm/v201806" xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201806"><SOAP-ENV:Header><ns1:RequestHeader><ns2:developerToken>MY_API_KEY_HERE</ns2:developerToken><ns2:userAgent>unknown (AwApi-PHP, googleads-php-lib/35.2.0, PHP/7.1.9)</ns2:userAgent><ns2:validateOnly>false</ns2:validateOnly><ns2:partialFailure>false</ns2:partialFailure></ns1:RequestHeader></SOAP-ENV:Header><SOAP-ENV:Body><ns1:getCustomers/></SOAP-ENV:Body></SOAP-ENV:Envelope>

The response (stripped out sensible information):

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><ResponseHeader xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201806" xmlns="https://adwords.google.com/api/adwords/mcm/v201806"><ns2:requestId>00056f9f586d04410a1b344ea10b1915</ns2:requestId><ns2:serviceName>CustomerService</ns2:serviceName><ns2:methodName>getCustomers</ns2:methodName><ns2:operations>0</ns2:operations><ns2:responseTime>138</ns2:responseTime></ResponseHeader></soap:Header><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>[QuotaCheckError.INVALID_TOKEN_HEADER @ ; trigger:'MY_API_KEY_HERE']</faultstring><detail><ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/mcm/v201806" xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201806"><ns2:message>[QuotaCheckError.INVALID_TOKEN_HEADER @ ; trigger:'MY_API_KEY_HERE']</ns2:message><ns2:ApplicationException.Type>ApiException</ns2:ApplicationException.Type><ns2:errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:QuotaCheckError"><ns2:fieldPath></ns2:fieldPath><ns2:trigger>MY_API_KEY_HERE</ns2:trigger><ns2:errorString>QuotaCheckError.INVALID_TOKEN_HEADER</ns2:errorString><ns2:ApiError.Type>QuotaCheckError</ns2:ApiError.Type><ns2:reason>INVALID_TOKEN_HEADER</ns2:reason></ns2:errors></ApiExceptionFault></detail></soap:Fault></soap:Body></soap:Envelope>

According to https://developers.google.com/adwords/api/docs/common-errors this error is associated, amongst the others, to a wrong namespace which should be https://adwords.google.com/api/adwords/cm/{version} <-- note as the last part in the call is not "cm" but "mcm"

What can I do to fix this?

Thanks!

Luis Xander Talag (AdWords API Team)

unread,
Jun 28, 2018, 3:13:56 AM6/28/18
to AdWords API and Google Ads API Forum
Hi Giacomo,

Could you clarify if you are using the AdWords API or the Google Ads API? Cause in this step "1. I've went to the Google API dashboard and enabled the Google Ads API from the library" is for Google Ads API only. However, your logs seems from the AdWords API service.

Moving forward, the QuotaCheckError.INVALID_TOKEN_HEADER error you encountered means that the developer token was not set on the request or it contains a typo or the namespace of the headers in the request might not be correct. Could you clarify if your developer token is correct? You can login to your AdWords MCC Account, go to Account Settings -> AdWords API Center, to verify the correct developer token. 

With regards to your RequestHeader, I'm not sure how you get the "https://adwords.google.com/api/adwords/mcm/v201806RequestHeader as it should be "https://adwords.google.com/api/adwords/cm/v201806" only. If you could confirm that your developer token is correct and the error still persist, I would suggest to post your issue here as the PHP client library owners are better equipped to assist you here.

Thanks and regards,
Luis
AdWords API Team

Giacomo Furlan

unread,
Jun 28, 2018, 5:15:15 AM6/28/18
to AdWords API and Google Ads API Forum
Hello Luis,

updates here. I've learnt that the developer key is not actually an API key, but an AdWords developer key (from the AdWords API Centre section of an administrative AdWords account). As per the first point thus it's not inherent anymore. I've created a MCC account now and applied for a basic developer token.

As per the request header, I think it's correct as per documentation: https://developers.google.com/adwords/api/docs/reference/v201806/CustomerService?hl=lb - not sure though if the common errors section is updated, or if I need special permissions.

Thanks :)

Giacomo

Luis Xander Talag (AdWords API Team)

unread,
Jun 28, 2018, 6:21:12 AM6/28/18
to AdWords API and Google Ads API Forum
Hi Giacomo,

I'm glad it works on your end. Seems the problem itself was in the developer token rather than the RequestHeader. I believe the documentation for QuotaCheckError.INVALID_TOKEN_HEADER is still updated since as per the common cause of the issue is either the developer token is not set on the request or it contains a typo or the namespace of the headers in the request is not correct. Feel free to write back if you have further clarifications.

Regards,
Luis
AdWords API Team
Reply all
Reply to author
Forward
0 new messages