So I added the following code into my “sendToChat” function by following the documentation to the best of my ability. Found an old example on this post:
However I still have the exact same 400 error. So either I made a mistake in the code or put it in the wrong place. Ty for the help so far.
var jwtPayload = {
'exp': Math.floor(new Date().getTime() / 1000) + 60,
'user_id': channelId,
'role': 'external'
}
const jwt = require('jsonwebtoken');
var signature = jwt.sign(jwtPayload, token)
console.log("sign: " + signature)
const requestOptions = {
method: 'POST',
headers:{ "Authorization": "Bearer " + signature,
"Client-ID": clientid,
"Content-Type": "application/json"},
body: textToBeSentToChat
};