INVALID_OAUTH_TOKEN_FOR_EMAIL

130 views
Skip to first unread message

cvit sandeep

unread,
Apr 1, 2015, 8:24:29 AM4/1/15
to adwor...@googlegroups.com
Hi Adwords Team,

When trying to implement AddGoogleMyBusinessLocationExtensions we get the following error.

[FeedError.INVALID_OAUTH_TOKEN_FOR_EMAIL @ operations[0].operand.systemFeedGenerationData.oAuthInfo; trigger:'Invalid token']

We already checked the email is matching with Adword UI.

Corresponding XML file is following.

[Apr 01 2015 08:22:49.000000 - ERROR] POST /api/adwords/cm/v201409/FeedService HTTP/1.1
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.5.12, gzip
Accept-Encoding: gzip, deflate
Content-Encoding: gzip
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Content-Length: 656
Authorization: Bearer ya29.SAHJ2zO4JlGePVGqzFQhgQe0TW89QZVHBAbB3M18RkV68cr5fUiP39BKwzVOayzZdfrVly8wMkgMQA

<?xml version="1.0" encoding="UTF-8"?>
  <SOAP-ENV:Header>
    <ns1:RequestHeader>
      <ns1:clientCustomerId>****</ns1:clientCustomerId>
      <ns1:developerToken>******</ns1:developerToken>
      <ns1:userAgent>Sistemim (AwApi-PHP/5.7.1, Common-PHP/5.7.1, PHP/5.5.12)</ns1:userAgent>
    </ns1:RequestHeader>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns1:mutate>
      <ns1:operations>
        <ns1:operator>ADD</ns1:operator>
        <ns1:operand>
          <ns1:name>Google My Business feed #551b8eb67e039</ns1:name>
          <ns1:origin>ADWORDS</ns1:origin>
          <ns1:systemFeedGenerationData xsi:type="ns1:PlacesLocationFeedData">
            <ns1:oAuthInfo>
              <ns1:httpMethod>GET</ns1:httpMethod>
              <ns1:httpRequestUrl>https://www.googleapis.com/auth/adwords</ns1:httpRequestUrl>
              <ns1:httpAuthorizationHeader>Bearer ******</ns1:httpAuthorizationHeader>
            </ns1:oAuthInfo>
            <ns1:emailAddress>tes...@sistemim.com.tr</ns1:emailAddress>
          </ns1:systemFeedGenerationData>
        </ns1:operand>
      </ns1:operations>
    </ns1:mutate>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

HTTP/1.1 500 Internal Server Error
Content-Type: text/xml; charset=UTF-8
Content-Encoding: gzip
Date: Wed, 01 Apr 2015 06:22:50 GMT
Expires: Wed, 01 Apr 2015 06:22:50 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Content-Length: 552
Server: GSE

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
      <requestId>000512a3be9014a10ab66828bd0044dd</requestId>
      <serviceName>FeedService</serviceName>
      <methodName>mutate</methodName>
      <operations>1</operations>
      <responseTime>842</responseTime>
    </ResponseHeader>
  </soap:Header>
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>[FeedError.INVALID_OAUTH_TOKEN_FOR_EMAIL @ operations[0].operand.systemFeedGenerationData.oAuthInfo; trigger:'Invalid token']</faultstring>
      <detail>
        <ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201409">
          <message>[FeedError.INVALID_OAUTH_TOKEN_FOR_EMAIL @ operations[0].operand.systemFeedGenerationData.oAuthInfo; trigger:'Invalid token']</message>
          <ApplicationException.Type>ApiException</ApplicationException.Type>
          <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="FeedError">
            <fieldPath>operations[0].operand.systemFeedGenerationData.oAuthInfo</fieldPath>
            <trigger>Invalid token</trigger>
            <errorString>FeedError.INVALID_OAUTH_TOKEN_FOR_EMAIL</errorString>
            <ApiError.Type>FeedError</ApiError.Type>
            <reason>UNKNOWN</reason>
          </errors>
        </ApiExceptionFault>
      </detail>
    </soap:Fault>
  </soap:Body>
</soap:Envelope>


 Regards

 sandeep

Josh Radcliff (AdWords API Team)

unread,
Apr 1, 2015, 3:04:53 PM4/1/15
to adwor...@googlegroups.com
Hi Sandeep,

That error means that the access token you included in PlacesLocationFeedData.oAuthInfo is revoked or expired or is not for the user you specified in the emailAddress attribute.

Please check out our location extensions guide for more details on how to populate the attributes of the PlacesLocationFeedData object.

Thanks,
Josh, AdWords API Team
            <ns1:emailAddress>testmcc@sistemim.com.tr</ns1:emailAddress>

Sergey Petrov

unread,
Apr 6, 2015, 11:39:19 AM4/6/15
to adwor...@googlegroups.com
Hi Josh ! 

I have same problem like Sandeep had before, but I can swear access token is actual, could you please take a look ? 

Request:

<soapenv:Envelope
    <soapenv:Header>
        <ns1:RequestHeader soapenv:mustUnderstand="0"
            <ns1:clientCustomerId>1195******</ns1:clientCustomerId>
            <ns1:developerToken>jwSU1DM5f1ziIPX6HqdcKA</ns1:developerToken>
            <ns1:userAgent>Kenshoo Demo (AwApi-Java, AdWords-Axis/1.34.0, Common-Java/1.34.0, Axis/1.4, Java/1.7.0_25, maven)</ns1:userAgent>
            <ns1:validateOnly>false</ns1:validateOnly>
            <ns1:partialFailure>false</ns1:partialFailure>
        </ns1:RequestHeader>
    </soapenv:Header>
    <soapenv:Body>
        <mutate
            <operations>
                <operator>ADD</operator>
                <operand>
                    <name>Google My Business feed #1428334036887</name>
                    <origin>ADWORDS</origin>
                    <systemFeedGenerationData xsi:type="ns2:PlacesLocationFeedData"
                        xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201409">
                        <oAuthInfo>
                            <httpMethod>GET</httpMethod>
                            <httpRequestUrl>https://www.googleapis.com/auth/adwords</httpRequestUrl>
                            <httpAuthorizationHeader>Bearer ya29.TQH6JLbutTeYctSQugRPwXNvQ_KiPufjLSsP_JGIlkqzntd16TLeu3MR</httpAuthorizationHeader>
                        </oAuthInfo>
                        <emailAddress>******@gmail.com</emailAddress>
                    </systemFeedGenerationData>
                </operand>
            </operations>
        </mutate>
    </soapenv:Body>
</soapenv:Envelope>

Response: 

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
    <soap:Header>
        <ResponseHeader
            <requestId>0005130fef1d47c00ac45f0369003431</requestId>
            <serviceName>FeedService</serviceName>
            <methodName>mutate</methodName>
            <operations>0</operations>
            <responseTime>542</responseTime>
        </ResponseHeader>
    </soap:Header>
    <soap:Body>
        <soap:Fault>
            <faultcode>soap:Server</faultcode>
            <faultstring>[FeedError.INVALID_OAUTH_TOKEN_FOR_EMAIL @ operations[0].operand.systemFeedGenerationData.oAuthInfo; trigger:'Invalid token']</faultstring>
            <detail>
                <ApiExceptionFault
                    xmlns="https://adwords.google.com/api/adwords/cm/v201409">
                    <message>[FeedError.INVALID_OAUTH_TOKEN_FOR_EMAIL @ operations[0].operand.systemFeedGenerationData.oAuthInfo; trigger:'Invalid token']</message>
                    <ApplicationException.Type>ApiException</ApplicationException.Type>
                    <errors xsi:type="FeedError"
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                        <fieldPath>operations[0].operand.systemFeedGenerationData.oAuthInfo</fieldPath>
                        <trigger>Invalid token</trigger>
                        <errorString>FeedError.INVALID_OAUTH_TOKEN_FOR_EMAIL</errorString>
                        <ApiError.Type>FeedError</ApiError.Type>
                        <reason>UNKNOWN</reason>
                    </errors>
                </ApiExceptionFault>
            </detail>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

-- best regards, Sergey. 


среда, 1 апреля 2015 г., 22:04:53 UTC+3 пользователь Josh Radcliff (AdWords API Team) написал:
Josh, AdWords API Team
            <ns1:emailAddress>tes...@sistemim.com.tr</ns1:emailAddress>

Josh Radcliff (AdWords API Team)

unread,
Apr 6, 2015, 2:05:34 PM4/6/15
to adwor...@googlegroups.com
Hi Sergey,

As a first step, please generate a new access token from your refresh token and then check its information by appending it to the end of the following URL:


That should return something like this:

{
 "issued_to": "12345....apps.googleusercontent.com",
 "audience": "12345....-.....apps.googleusercontent.com",
 "expires_in": 3596,
 "access_type": "offline"
}

Note that you need to do this before the access token expires (each access token is valid for approximately one hour).

Please confirm that the scope matches the scope shown above.

Thanks,
Josh, AdWords API Team

Sergey Petrov

unread,
Apr 7, 2015, 4:03:57 AM4/7/15
to adwor...@googlegroups.com
Hi Josh ! 
Great thanks for the answer, I think you find the problem point, because when I verify accessToken I get a many scopes but not that what I need: 

{
 "issued_to": "*********.apps.googleusercontent.com",
 "audience": "*********.apps.googleusercontent.com",
"user_id": "1076******", "scope": "https://adwords.google.com/api/adwords/ https://www.google.com/local/add/ https://www.googleapis.com/auth/analytics.readonly https://www.googleapis.com/auth/plus.me", "expires_in": 3566, "access_type": "offline" }

That is strange because when I get create OAuthInfo object I use that scope  oAuthInfo.setHttpRequestUrl("https://www.googleapis.com/auth/adwords");

Did I miss something ? 

-- best regards, Sergey.


понедельник, 6 апреля 2015 г., 21:05:34 UTC+3 пользователь Josh Radcliff (AdWords API Team) написал:

Josh Radcliff (AdWords API Team)

unread,
Apr 7, 2015, 9:27:39 AM4/7/15
to adwor...@googlegroups.com
Hi Sergey,

You are setting the OAuthInfo object correctly, but your refresh token was created using the old, deprecated scope of https://adwords.google.com/api/adwords/. You could try setting oAuthInfo.setHttpRequestUrl("https://adwords.google.com/api/adwords/"), but I would recommend against that approach because that scope is deprecated. A better approach would be:

1. Generate a new refresh token using the new scope of https://www.googleapis.com/auth/adwords
2. Use an access token generated from the new refresh token in your OAuthInfo, and set oAuthInfo.setHttpRequestUrl("https://www.googleapis.com/auth/adwords")

The key point here is that when creating an OAuthInfo object, the scope used to generate the refresh token (and the access token) must be an AdWords scope and must match the scope specified in setHttpRequestUrl.

Cheers,
Josh, AdWords API Team
Reply all
Reply to author
Forward
0 new messages