[ManagedCustomerServiceError.NOT_AUTHORIZED @ operations[0]]

239 views
Skip to first unread message

Bryan Natter

unread,
Jul 2, 2018, 1:16:32 AM7/2/18
to AdWords API and Google Ads API Forum
I am trying to send an invite to link and account with our MCC account. I keep getting [ManagedCustomerServiceError.NOT_AUTHORIZED @ operations[0]] error when i try to send invite.
The developer token with client id was created by a user with admin access. Also the user of the account that has been oauth that we are trying to link also has admin access.

This is the code im using to send the link
$linkOperation = new LinkOperation();
$managedCustomerLink = new ManagedCustomerLink();
$managedCustomerLink->setClientCustomerId($clientAdwordsId);
$managedCustomerLink->setLinkStatus(LinkStatus::PENDING);
$managedCustomerLink->setManagerCustomerId($managerAdwordsId);
$linkOperation->setOperand($managedCustomerLink);
$linkOperation->setOperator(Operator::ADD);
$session = $this->getAdWordsSession();
$adWordsServices = new AdWordsServices();
/** @var  ManagedCustomerService $adService */
$adService = $adWordsServices->get($session, ManagedCustomerService::class);
$response = $adService->mutateLink([$linkOperation]);

This is the xml we are sending to google with credentials stripped out
<?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/cm/v201806" xmlns:ns2="https://adwords.google.com/api/adwords/mcm/v201806">
   <SOAP-ENV:Header>
      <ns2:RequestHeader>
         <ns1:clientCustomerId>XXX-XXX-XXXX</ns1:clientCustomerId>
         <ns1:developerToken>XXXXXXXXXXX</ns1:developerToken>
         <ns1:userAgent>SandO (AwApi-PHP, googleads-php-lib/35.2.0, PHP/5.6.14-1+deb.sury.org~trusty+1)</ns1:userAgent>
         <ns1:validateOnly>false</ns1:validateOnly>
         <ns1:partialFailure>false</ns1:partialFailure>
      </ns2:RequestHeader>
   </SOAP-ENV:Header>
   <SOAP-ENV:Body>
      <ns2:mutateLink>
         <ns2:operations>
            <ns1:operator>ADD</ns1:operator>
            <ns2:operand>
               <ns2:managerCustomerId>XXXXXXXXX</ns2:managerCustomerId>
               <ns2:clientCustomerId>XXXXXXXXXX</ns2:clientCustomerId>
               <ns2:linkStatus>PENDING</ns2:linkStatus>
            </ns2:operand>
         </ns2:operations>
      </ns2:mutateLink>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


This is the response we get back from google
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Header>
      <ns2:ResponseHeader xmlns:ns2="https://adwords.google.com/api/adwords/mcm/v201806" xmlns="https://adwords.google.com/api/adwords/cm/v201806">
         <requestId>00056fc8e30c69280ac155ea820d4bcd</requestId>
         <serviceName>ManagedCustomerService</serviceName>
         <methodName>mutateLink</methodName>
         <operations>1</operations>
         <responseTime>192</responseTime>
      </ns2:ResponseHeader>
   </soap:Header>
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Server</faultcode>
         <faultstring>[ManagedCustomerServiceError.NOT_AUTHORIZED @ operations[0]]</faultstring>
         <detail>
            <ns2:ApiExceptionFault xmlns:ns2="https://adwords.google.com/api/adwords/mcm/v201806" xmlns="https://adwords.google.com/api/adwords/cm/v201806">
               <message>[ManagedCustomerServiceError.NOT_AUTHORIZED @ operations[0]]</message>
               <ApplicationException.Type>ApiException</ApplicationException.Type>
               <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:ManagedCustomerServiceError">
                  <fieldPath>operations[0]</fieldPath>
                  <fieldPathElements>
                     <field>operations</field>
                     <index>0</index>
                  </fieldPathElements>
                  <trigger />
                  <errorString>ManagedCustomerServiceError.NOT_AUTHORIZED</errorString>
                  <ApiError.Type>ManagedCustomerServiceError</ApiError.Type>
                  <ns2:reason>NOT_AUTHORIZED</ns2:reason>
               </errors>
            </ns2:ApiExceptionFault>
         </detail>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>


Any ideas on how I can get past this error
Thanks

Luis Xander Talag (AdWords API Team)

unread,
Jul 2, 2018, 3:06:29 AM7/2/18
to AdWords API and Google Ads API Forum
Hi Bryan,

To further investigate this, could you provide the complete SOAP request logs with unmask clientCustomerId and manageCustomerId and the email address used to generated the OAuth2 credentials of the client customer ID that is making this request? Please reply via Reply privately to author.

Thanks and regards,
Luis
AdWords API Team

Bryan Natter

unread,
Jul 2, 2018, 10:26:44 AM7/2/18
to AdWords API and Google Ads API Forum
I sent the SOAP request privately as requested

Thank you

Bryan

unread,
Jul 3, 2018, 10:42:00 AM7/3/18
to AdWords API and Google Ads API Forum
Luis

I did what you recommended i do for my SOAP request. My SOAP request looks exactly like example you sent back to me
My new error message response is:

<?xml version="1.0"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
        <ns2:ResponseHeader xmlns:ns2="https://adwords.google.com/api/adwords/mcm/v201806" xmlns="https://adwords.google.com/api/adwords/cm/v201806">
            <requestId>000570190beb42b00a8189845b0a4187</requestId>

            <serviceName>ManagedCustomerService</serviceName>
            <methodName>mutateLink</methodName>
            <operations>1</operations>
            <responseTime>113</responseTime>

        </ns2:ResponseHeader>
    </soap:Header>
    <soap:Body>
        <soap:Fault>
            <faultcode>soap:Server</faultcode>
            <faultstring>[AuthorizationError.USER_PERMISSION_DENIED @ ; trigger:'&lt;null&gt;']</faultstring>
            <detail>
                <ns2:ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201806" xmlns:ns2="https://adwords.google.com/api/adwords/mcm/v201806">
                    <message>[AuthorizationError.USER_PERMISSION_DENIED @ ; trigger:'&lt;null&gt;']</message>
                    <ApplicationException.Type>ApiException</ApplicationException.Type>
                    <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AuthorizationError">
                        <fieldPath/>
                        <trigger>&lt;null&gt;</trigger>
                        <errorString>AuthorizationError.USER_PERMISSION_DENIED</errorString>
                        <ApiError.Type>AuthorizationError</ApiError.Type>
                        <reason>USER_PERMISSION_DENIED</reason>

                    </errors>
                </ns2:ApiExceptionFault>
            </detail>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

I will also send private message with the SOAP request for you to analyze

Bryan

unread,
Jul 6, 2018, 9:07:44 AM7/6/18
to AdWords API and Google Ads API Forum
Luis

you had recommended in private message that i recreate my oauth credentials using this email address. I created new oauth credentials and i tried the request with the new client id and client secret.
I still get the same error as above USER_PERMISSION_DENIED

Not sure what else to try to get this working
Ill private message SOAP request again for you

Thanks
Reply all
Reply to author
Forward
0 new messages