Apps脚本插件:如何跟踪管理域安装?

问题描述 投票:0回答:1

我正在尝试获取安装了我的插件的用户的电子邮件列表。

我正在使用onInstall触发器来获取电子邮件并将其推送到我的数据库。

这对于单独安装(正常的gmail或选择单独安装的管理员来说很好)

但是使用Domain Install时,未触发onInstall事件

那么我如何跟踪域安装?

google-apps-script google-apps-marketplace google-apps-script-addon
1个回答
0
投票

我们可以使用G Suite Marketplace API的LicenseNotification端点:

https://developers.google.com/gsuite/marketplace/v2/reference/licenseNotification/list

结果将是这样的:

{
  "kind": "appsmarket#licenseNotificationList",
  "notifications": [
    {
      "kind": "appsmarket#licenseNotification",
      "id": "001566972002228000-000001",
      "applicationId": "xxx",
      "customerId": "[email protected]",
      "timestamp": "1566972001590",
      "provisions": [
        {
          "kind": "appsmarket#provisionNotification",
          "editionId": "default_edition",
          "seatCount": "1"
        }
      ]
    },
    {
      "kind": "appsmarket#licenseNotification",
      "id": "001568364120883000-000001",
      "applicationId": "xxx",
      "customerId": "domainabc.com",
      "timestamp": "1568364119585",
      "provisions": [
        {
          "kind": "appsmarket#provisionNotification",
          "editionId": "default_edition",
          "seatCount": "-1"
        }
      ]
    },
    ...
  ],
  "nextPageToken": "001569976724468000-000001"
}

notifications数组内部,请注意一些具有"seatCount": "-1"的对象

这些是我们正在寻找的域安装。

我们只需要获取"customerId": "domainabc.com",中的值

© www.soinside.com 2019 - 2024. All rights reserved.