我正在尝试获取安装了我的插件的用户的电子邮件列表。
我正在使用onInstall
触发器来获取电子邮件并将其推送到我的数据库。
这对于单独安装(正常的gmail或选择单独安装的管理员来说很好)
但是使用Domain Install
时,未触发onInstall
事件
那么我如何跟踪域安装?
我们可以使用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",
中的值