如何在我的应用程序中将其他用户的refresh_token用于Google AdWords?

时间:2018-11-05 02:56:28

标签: node.js google-api google-adwords

我有一个Google AdWords经理帐户,可以在我的平台上管理我们用户的广告帐户。

如果用户想要授权我,则需要给我客户ID(广告帐户)

  • 使用连接我的Google帐户的 refresh_token 时,我可以邀请任何客户ID 进行链接。

  • 但是,如果用户使用通过连接其Google帐户获得的 refresh_token ,它将获得USER_PERMISSION_DENIED

我的问题是

只有经理帐户的 refresh_token 可以通过AdWords API邀请某人吗?

那么,用户/经理的 refresh_token 能做什么?

node-adwords,这是我使用的库。

-------- 11/12更新 --------

let user = new AdwordsUser({
  "client_id": "xxxxxxxxxxx.apps.googleusercontent.com",
  "client_secret": "xxxxxxxxxxx",
  "developerToken": "xxxxxxxxxx",
  "userAgent": "xxxx",
  "clientCustomerId": "mcc-account id",
  "debug": "true"
});

// linked customer.
user.credentials.refresh_token = 'refreshToken' (user's or mcc-account's?)

const managedCustomerService = user.getService('ManagedCustomerService', apiVersion);
const managerCustomerId = +user.credentials.clientCustomerId.split('-').join('');
const clientCustomerId = +clientId.split('-').join('');

const operation = {
  operator: 'ADD',
  operand: {
    managerCustomerId,
    clientCustomerId,
    linkStatus: 'PENDING',
    pendingDescriptiveName: 'invitation',
    isHidden: false,
  }
}

managedCustomerService.mutateLink({operations: [operation]}, (error, result)....

1 个答案:

答案 0 :(得分:0)

  1. 是的,只有经理帐户可以向其他要管理的adwords用户发送邀请。

  2. 这是与此问题相关的官方google adwords doc。您需要阅读有关身份验证的部分(页面底部附近)。有一个图表显示了adwords帐户的管理层次结构。换句话说,您可以通过管理员令牌对用户帐户进行操作(受影响的帐户取决于用户凭据adwords user id中指定的new AdwordsUser({clientCustomerId: 'xxxxxxxxxx'}))。

您也不必警惕:

+clientId.split('-').join('');

node-adwords lib或adwords API可与xxxxxxxxxxxxx-xxx-xxxx一起使用

我希望它能有所帮助。