Link client to Mcc Account

68 views
Skip to first unread message

asma batool

unread,
Jun 20, 2016, 5:41:47 AM6/20/16
to AdWords API Forum
Hi,

I am trying to Link a google use account to Mcc acount

this is my code

$user = new AdWordsUser();
            //$user->SetDeveloperToken($developerToken);
            $user->SetOAuth2Info(array(
                "client_id" => $clientId,
                "client_secret" => $clientSecret
            ));
            
                $code = $_REQUEST["code"];
                $oAuth2Handler = $user->getOAuth2Handler();
          // echo $oAuth2Handler->GetOAuth2AccessToken($authCode, $callbackUrl);
             $user_info =    $user->SetOAuth2Info(
                $oAuth2Handler->GetAccessToken($user->GetOAuth2Info(), $code, $callbackUrl));
            
                 $oauthInfo = $user->GetOAuth2Info();
                 $customerService = $user->GetService("CustomerService");
                $customer = $customerService->get();
               // echo $customer->customerId; exit;
                 $user->SetClientCustomerId($customer->customerId);
 $managedCustomerService =
                $user->GetService('ManagedCustomerService', 'v201603');

            // Create customer.
            $customer = new ManagedCustomer();
            $customer->name = 'Account #' . uniqid();
            $customer->currencyCode = 'EUR';
            $customer->dateTimeZone = 'Europe/London';
            //$customer->email

            // Create operation.
            $operation = new ManagedCustomerOperation();
            $operation->operator = 'ADD';
            $operation->operand = $customer;

            $operations = array($operation);

            // Make the mutate request.
            $result = $managedCustomerService->mutate($operations);
//            print '<pre>';
           $customer = $result->value[0];

But this error is getting

ManagedCustomerServiceError.NOT_AUTHORIZED @ operations[0]


Please help me


Shwetha Vastrad (AdWords API Team)

unread,
Jun 20, 2016, 4:04:13 PM6/20/16
to AdWords API Forum
Hi,

The NOT_AUTHORIZED error indicates that the account whose OAuth credentials are used to make this request is not authorized to perform this operation. You would need to have either Administrative or Managed-Standard access to link accounts to a manager account. Please see this document for more information on different access levels for manager account users.

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