I used Directory API push notifications example of https://stackoverflow.com/users/6586255/dimu-designs from this question: Is it possible to watch Directory API changes from Google App Maker/Google Apps Script?
I have two projects setup, another one is webhook itself:
/** HTTP GET request handler */
function doGet(e) {
return ContentService.createTextOutput("GET message");
}
/** HTTP POST request handler */
function doPost(e) {
return ContentService.createTextOutput("POST message");
}
And other one is the watch request:
function startUpdateWatch() {
var channel = AdminDirectory.newChannel(),
receivingURL = "https://script.google.com/macros/s/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/exec",
gSuiteDomain = "[business-name].com",
event = "update";
channel.id = Utilities.getUuid();
channel.type = "web_hook";
channel.address = receivingURL + "?domain=" + gSuiteDomain + "&event=" + event;
channel.expiration = Date.now() + 21600000; // max of 6 hours in the future; Note: watch must be renew before expiration to keep sending notifications
AdminDirectory.Users.watch(
channel,
{
"domain":gSuiteDomain,
"event":event
}
);
}
Webhook url works fine, it fires "Get" when I try to open it via browser. startUpdateWatch function starts fine as well without errors and if I try to change the url to something else, I get an error, so that receiving url should be ok as well.
How you debug that push channel? I have tried to launch function with different events like 'add' and 'delete' as well and then deleted/added/modified user in G suite, but no push from that function towards the url.