Created
February 21, 2016 13:42
-
-
Save spasiu/d90b3a3368d6f5509e52 to your computer and use it in GitHub Desktop.
create webhook with node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var request = require('superagent'); | |
| var jwt = require('jsonwebtoken'); | |
| var USER_ID = 'appUser _id'; | |
| var KEY_ID = 'your_key_id'; | |
| var SECRET = 'your_secret'; | |
| var token = jwt.sign({ | |
| scope: 'app' | |
| }, | |
| SECRET, | |
| { | |
| headers: { | |
| kid: KEY_ID | |
| } | |
| }); | |
| request | |
| .post('https://api.smooch.io/v1/webhooks') | |
| .send({target: 'http://example.com/callback'}) | |
| .set('authorization', 'Bearer ' + token) | |
| .set('Accept', 'application/json') | |
| .set('content-type', 'application/json') | |
| .end(function(err, res) { | |
| console.log(err, res.body, res.statusCode); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment