Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get an adwords account client customer id to link it to a MCC account?

I'd like to add an Adwords account to a MCC account via Google Adwords API on my web application. I guess I just need to add a ManagedCustomerLink

The thing is I don't know how to get clientCustomerId. I thought by authenticating the user via OAuth2 on my application with the matching scope, I could somehow get their clientCustomerId but I could not find it.

Thank you by advance for your help !

like image 239
sinhix Avatar asked Nov 10 '22 08:11

sinhix


1 Answers

You can get the client customer id by running the next code:

CustomerServiceInterface customerService = adWordsServices.get(session, CustomerServiceInterface.class);
Customer[] customers;
try {
    customers = customerService.getCustomers();
    for (Customer customer : customers) {
        Long customerId = customer.getCustomerId();
        System.out.println(customerId);
    }
} catch (RemoteException e) {
    e.printStackTrace();
}

In order to get the user session you have to use Oauth 2.0 and ask for his credentials.

like image 121
Alan Albertengo Avatar answered Dec 16 '22 20:12

Alan Albertengo