Link Account To Manager

47 views
Skip to first unread message

xuantoi....@gmail.com

unread,
Oct 19, 2021, 9:15:45 AM10/19/21
to AdWords API and Google Ads API Forum
Hi,

I have 2 mcc test accounts M1 and M2, M2 have 1 client account C2.
I want link C2 to M1, here is my step: 
login account M2 to get Access token (googleUser.getAuthResponse().access_token)


I got stuck when Accept the link using the client account.

here is my java code to accept:

AccessToken accessToken = new AccessToken(Token from Step 1, new Date(expireTime));
Credentials credentials = new GoogleCredentials(accessToken);
GoogleAdsClient client = GoogleAdsClient.newBuilder()
.setCredentials(credentials)
.setDeveloperToken(developerToken)
.setLoginCustomerId(M2 customer Id)
.build();

CustomerManagerLinkOperation.Builder managerLinkOp = CustomerManagerLinkOperation.newBuilder();
managerLinkOp
.getUpdateBuilder()
.setResourceName(
ResourceNames.customerManagerLink(C2 customer Id, M1 customer Id, managerLinkId))
.setStatus(ManagerLinkStatusEnum.ManagerLinkStatus.ACTIVE);

managerLinkOp.setUpdateMask(FieldMasks.allSetFieldsOf(managerLinkOp.getUpdate()));

acceptService.mutateCustomerManagerLink(String.valueOf(C2 customer Id), Collections.singletonList(managerLinkOp.build()));

but it return error:
[error_code {
  authorization_error: USER_PERMISSION_DENIED
}
message: "User doesn\'t have permission to access customer. Note: If you\'re accessing a client customer, the manager\'s customer id must be set in the \'login-customer-id\' header. See https://developers.google.com/google-ads/api/docs/concepts/call-structure#cid"
]

do I miss anything ?
 

Google Ads API Forum Advisor

unread,
Oct 19, 2021, 9:25:19 PM10/19/21
to xuantoi....@gmail.com, adwor...@googlegroups.com
Hi Duong,

Thank you for posting your concern.

I can see that you encountered the USER_PERMISSION_DENIED error and it occurs when authenticating as a user with access to a manager account but not specifying login-customer-id in the request.

With this, could you confirm if you already tried the suggestion in the error message? If you haven't tried yet, then please follow the instruction below:
1. First determine the manager account that you want to link with the client account
2. Generate Oauth2 credential using email address that have access to the manager account and configure it to your client library
2. Set the customer ID of the manager account to the login_customer_id field. Ensure to remove the hyphen ('-') of the customer ID before setting it up
3. Set the customer ID of client account to the customer_id field and without hyphen ('-') as well
4. Try the API request again

If the error persists, please provide the complete request and response logs with request ID and request header generated on your end. You can provide it via Reply privately to author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.

Regards,
Google Logo
Ernie John Blanca Tacata
Google Ads API Team
 


ref:_00D1U1174p._5004Q2PKp4b:ref
Reply all
Reply to author
Forward
0 new messages