question

snehal sutar avatar image
snehal sutar asked Phong Vu answered

Cannot access tokens to integrate webhook in developer sandbox account

I am trying to integrate glip webhook in my SharePoint online/office 365 modern page,I have developer/sandbox account and created sandbox app.trying to post messages via a glip webhook.How i can access token to call/use API??

how i can access token
1 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

·
Phong Vu avatar image
Phong Vu answered

You don't need an access token to post a Glip webhook message. However, if you don't know your Glip Webhook address and want to detect it programmatically, then you can login your app and call the glip/webhooks endpoint to get a list of webhooks addresses.

To post a message to a Glip Webhook, read this blog for details on how to set it up and use any http POST request to send.

Here is some snippet code to post a message in Node JS, provided that you have the webhook_url

function post_message_to_group(){
  webhook_url = "https://hooks-glip.devtest.ringcentral.com/webhook/v2/f4baa67a-xx"
  var https = require('https');
  var url = webhook_url.replace("https://", "")
  var urlArr = url.split("/")
  var host = urlArr[0]
  var path = url.replace(host, "")
  var body = {
    "icon": "http://tinyurl.com/pn46fgp",
    "activity": "Beer consumed",
    "title": "Let's stop working and go to WaterDog to have a bear.",
    "body": "This is the body of the post"
  }
  var post_options = {
      host: host,
      path: path,
      method: "POST",
      headers: {
        'Content-Type': 'application/json'
      }
  }
  var post_req = https.request(post_options, function(res) {
      var response = ""
      res.on('data', function (chunk) {
          response += chunk
      });
      res.on("end", function(){
        console.log(response)
      });
  });
  post_req.write(JSON.stringify(body));
  post_req.end();
}
1 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.