Webhook Validation using Google Apps Script

Hello,

I am having trouble validating my endpoint, which is a Google Apps Script.

Endpoint Google Apps Script code

const sT = "XXXXXXXXXXX"

function doPost(e) {

  const requestMessage = e.postData.contents;
  const requestJSON = JSON.parse(requestMessage)
  const pT = requestJSON.payload.plainToken
  var signature = Utilities.computeHmacSha256Signature(pT, sT, Utilities.Charset.US_ASCII);
  var hexString = signature
    .map(function (byte) {
      // Convert from 2's compliment
      var v = (byte < 0) ? 256 + byte : byte;

      // Convert byte to hexadecimal
      return ("0" + v.toString(16)).slice(-2);
    })
    .join("");

  const response = {
    plainToken: pT,
    encryptedToken: hexString
  }

  return JSON.stringify(response)
}

The validation always fails. I have tried several formats for the return function. Not sure what is wrong, and there is not explicit example I can find.

Thanks so much!

Here is the session regarding Webhook Validation. If still a problem then please share it here. Thanks

Thanks for your reply, but it was for Node.js. I meant for Google Apps script.

@shinseikaikanoffice @elisa.zoom @donte.zoom I tested locally with google script and nodejs working crypto js sample generated encryptedTokens both are the same.

But the issue is google script needs a pre-flight request with the 302 Found redirect and that is the actual issue from the (Client Side/App Validate Button) webhook validation with the google script endpoints.

For reference attaching both screenshots of the Google Script API response :point_down:

The localhost:3000 NodeJS working sample response (**same**) :point_down:

1 Like

@freelancer.nak Thank you for the all checkups. I understand that the problem is google apps script response. It is impossible to change the google apps script response, so the solution is having a new node.js server for the zoom webhooks. Is it right?

@elisa.zoom @donte.zoom Please verify from engineers, what is going wrong when validating the webhooks endpoint with google script endpoint.

For now, we will wait until get the response from @elisa.zoom @donte.zoom.

@freelancer.nak @elisa.zoom @donte.zoom
Thank you for your replies.
I gave up doing by Google Apps Script, and I am making a node.js server. It is working.(endpoint verification part has been done).

1 Like

@shinseikaikanoffice Great. Welcome & Thanks

1 Like

Now is the problem with webhook validation in goole app script is solved or not ???
me to wanted to verify webhook in google app script
@freelancer.nak @shinseikaikanoffice @freelancer.nak