问题
I'm trying to get the list of emails of users who installed my addon.
I'm using the onInstall trigger to get the email and push it to my database.
This is fine with individual installation (normal gmail or even admin who chooses to Individual Install)
But with Domain Install, onInstall event was not fired
So how can I track the Domain Installation?
回答1:
We can use the LicenseNotification endpoint of the G Suite Marketplace API:
https://developers.google.com/gsuite/marketplace/v2/reference/licenseNotification/list
The result will be something like this:
{
"kind": "appsmarket#licenseNotificationList",
"notifications": [
{
"kind": "appsmarket#licenseNotification",
"id": "001566972002228000-000001",
"applicationId": "xxx",
"customerId": "test@gmail.com",
"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"
}
Inside the notifications array, notice some object that has "seatCount": "-1"
Those are domain installations that we are looking for.
We just need to get the value inside "customerId": "domainabc.com",
来源:https://stackoverflow.com/questions/57943614/apps-script-addon-how-to-track-admin-domain-install