QuotaCheckError.INVALID_TOKEN_HEADER with the PHP v201603 API provided examples

103 views
Skip to first unread message

Clément Prévost

unread,
Apr 26, 2016, 8:58:21 AM4/26/16
to AdWords API Forum
Hi,

I try to use the GetCampaign.php example provided in the php API bundle here (git tag 8.3.0): https://github.com/googleads/googleads-php-lib/blob/8.3.0/examples/AdWords/v201603/BasicOperations/GetCampaigns.php

I filled in the auth.ini file here with my developer token, userAgent, clientCustomerd, client_id and client_secret: https://github.com/googleads/googleads-php-lib/blob/8.3.0/src/Google/Api/Ads/AdWords/auth.ini
I successfully used the GetRefreshToken.php script to generate my refresh token: https://github.com/googleads/googleads-php-lib/blob/8.3.0/examples/AdWords/Auth/GetRefreshToken.php

But when I try to use the provided GetCampaings script, I get this error (The anonymized part is my developer token.):
 An error has occurred: [QuotaCheckError.INVALID_TOKEN_HEADER @ ; trigger:'xxxxxxxx_xxxxxxxxxxxxxx']

I really don't know what's going on as I didn't write a single line of PHP and only used provided examples.

The weird part is that the AdWords server respond with a 500 error and the header is obviously syntactically "valid".

Below is the full SOAP log generated by the library:

[Apr 26 2016 11:20:57.000000 - ERROR] POST /api/adwords/cm/v201603/CampaignService HTTP/1.1
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.6.20-1+deb.sury.org~trusty+1, gzip
Accept-Encoding: gzip, deflate
Content-Encoding: gzip
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Content-Length: 474
Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

<?xml version="1.0" encoding="UTF-8"?>
  <SOAP-ENV:Header>
    <ns1:RequestHeader>
      <ns1:clientCustomerId>xxx-xxx-xxxx</ns1:clientCustomerId>
      <ns1:developerToken>xxxxxxxx_xxxxxxxxxxxxxx</ns1:developerToken>
      <ns1:userAgent>x.xxxxxxxx.com:xxxxxxxxxxxxx:V0.0.1 (AwApi-PHP/8.3.0, Common-PHP/8.3.0, PHP/5.6.20-1+deb.sury.org~trusty+1)</ns1:userAgent>
    </ns1:RequestHeader>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns1:get>
      <ns1:serviceSelector>
        <ns1:fields>Id</ns1:fields>
        <ns1:fields>Name</ns1:fields>
        <ns1:ordering>
          <ns1:field>Name</ns1:field>
          <ns1:sortOrder>ASCENDING</ns1:sortOrder>
        </ns1:ordering>
        <ns1:paging>
          <ns1:startIndex>0</ns1:startIndex>
          <ns1:numberResults>500</ns1:numberResults>
        </ns1:paging>
      </ns1:serviceSelector>
    </ns1:get>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

HTTP/1.1 500 Internal Server Error
Content-Type: text/xml; charset=UTF-8
Content-Encoding: gzip
Date: Tue, 26 Apr 2016 09:20:57 GMT
Expires: Tue, 26 Apr 2016 09:20:57 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Transfer-Encoding: chunked

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
      <requestId>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</requestId>
      <serviceName>CampaignService</serviceName>
      <methodName>get</methodName>
      <operations>1</operations>
      <responseTime>14</responseTime>
    </ResponseHeader>
  </soap:Header>
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>[QuotaCheckError.INVALID_TOKEN_HEADER @ ; trigger:'xxxxxxxx_xxxxxxxxxxxxxx']</faultstring>
      <detail>
        <ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201603">
          <message>[QuotaCheckError.INVALID_TOKEN_HEADER @ ; trigger:'xxxxxxxx_xxxxxxxxxxxxxx']</message>
          <ApplicationException.Type>ApiException</ApplicationException.Type>
          <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="QuotaCheckError">
            <fieldPath/>
            <trigger>xxxxxxxx_xxxxxxxxxxxxxx</trigger>
            <errorString>QuotaCheckError.INVALID_TOKEN_HEADER</errorString>
            <ApiError.Type>QuotaCheckError</ApiError.Type>
            <reason>INVALID_TOKEN_HEADER</reason>
          </errors>
        </ApiExceptionFault>
      </detail>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>

Umesh Dengale

unread,
Apr 26, 2016, 3:51:42 PM4/26/16
to AdWords API Forum
Hello,

The INVALID_TOKEN_HEADER error is due to these reasons  1)developer token is not set on the request or it contains a typo. 2)The namespace of the headers in the request is not correct. Please verify your request.


Thanks,
Umesh, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages