MCC - get client customer ID and link it under our MCC

71 views
Skip to first unread message

Ahmed Adly

unread,
Nov 10, 2020, 12:49:57 AM11/10/20
to AdWords API and Google Ads API Forum
Hello,
We are creating an app to manage google ads on behalf of our customers. We have done the following so far: 
  • created a manager account (MCC) and got it approved 
  • created the UI and flow to get the user to authenticate using google Oauth2 API with the scope 'https://www.googleapis.com/auth/adwords
  • currently, we are able to retrieve the access token and refresh token correctly
Now we need to be able to create campaigns on behalf of the customer. As i understand that we need to link the customer google ads account to be under our MCC account according to the link here: https://developers.google.com/google-ads/api/docs/account-management/linking-manager-accounts 

my questions: 
  • according to the doc above we need to have the client customer ID (google ads account id: for ex: 698-569-3448), is there a way that we retrieve this customer ID via the token and fresh token? or we have to get the user to enter it manually? 
  • does the process of linking the customer account require ui redirection and concent again (after the initial oauth2 mentioned above) or no? 

Thank you,





Ahmed Adly

unread,
Nov 10, 2020, 1:13:55 AM11/10/20
to AdWords API and Google Ads API Forum
Note: we can use either Node JS or java client library if needed.

Google Ads API Forum Advisor Prod

unread,
Nov 10, 2020, 4:21:25 PM11/10/20
to ahme...@gmail.com, adwor...@googlegroups.com

Hi Ahmed,

Thank you for reaching out. Please find my response to your questions below:
 

  1. The user has to send the client customer id. It could not be retrieved via the developer token or refresh token.
     

  2. This linking process could be done by authenticating as the manager account and client customer account and following this flow.

 

Thanks and regards,
Xiaoming, Google Ads API Team

 

Google Logo
Xiaoming
Google Ads API Team
 


ref:_00D1U1174p._5004Q27sdUn:ref

Ahmed Adly

unread,
Nov 10, 2020, 6:25:28 PM11/10/20
to Google Ads API Forum Advisor Prod, adwor...@googlegroups.com
Hello Xiaoming,
Thank you very much for replying. Can you let me know how can I achieve the flow in this video? https://drive.google.com/file/d/1wgykhFIIkCaIujhkicVC0t4a-G4r8_2e/view?usp=sharing



Specifically, how to reach this screen: 

Screen Shot 2020-11-10 at 5.23.30 PM.png



Thank you,
Ahmed

Ahmed Adly

unread,
Nov 10, 2020, 10:34:20 PM11/10/20
to Google Ads API Forum Advisor Prod, adwor...@googlegroups.com
Hello Xiaoming,
I was able to get the customer ID using the refresh token via google adword api: https://developers.google.com/adwords/api/docs/guides/start 

the code is below, what do you think?


Credential credential = new OfflineCredentials.Builder()
.forApi(OfflineCredentials.Api.ADWORDS)
.withClientSecrets(OAUTH_CLIENT_ID, OAUTH_CLIENT_SECRET)
.withRefreshToken(REFRESH_TOKEN)
.build()
.generateCredential();
AdWordsSession session =
new AdWordsSession.Builder()
.withDeveloperToken(DEVELOPER_TOKEN)
.withOAuth2Credential(credential).build();
AdWordsServicesInterface adWordsServices = AdWordsServices.getInstance();
CustomerServiceInterface customerServiceInterface = adWordsServices.get(session, CustomerServiceInterface.class);

Customer[] customers = customerServiceInterface.getCustomers();

for (int i = 0; i < customers.length; i++) {
Customer c = customers[i];
System.out.println("customer Id: " +c.getCustomerId());
System.out.println("customer name : " +c.getDescriptiveName());
System.out.println(" ===================== ");
}
Reply all
Reply to author
Forward
0 new messages