v1.5.1/chip fix

This commit is contained in:
2020-07-25 19:30:57 -04:00
parent 6f7a8c0f6f
commit 1e2386713e
4 changed files with 54 additions and 35 deletions
+18 -17
View File
@@ -1,21 +1,22 @@
const VoxeetSecret = require('../VoxeetSecret.json');
const fetch = require('node-fetch');
module.exports = async (req, res) => {
const { key, secret } = VoxeetSecret;
const credentials = Buffer.from(encodeURI(key) + ':' + encodeURI(secret)).toString('base64');
const headers = {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache',
Authorization: 'Basic ' + credentials,
};
const oauth = await fetch(VoxeetSecret.validateURL, {
method: 'POST',
headers,
body: JSON.stringify({
grant_type: 'client_credentials',
}),
})
.then((oauthResponse) => oauthResponse.json())
.catch((err) => res.status(500).send(err));
if (oauth) res.status(200).send(oauth);
res.status(403).send({ message: 'Voice calls are unavailable temporarily.' });
// const { key, secret } = VoxeetSecret;
// const credentials = Buffer.from(encodeURI(key) + ':' + encodeURI(secret)).toString('base64');
// const headers = {
// 'Content-Type': 'application/json',
// 'Cache-Control': 'no-cache',
// Authorization: 'Basic ' + credentials,
// };
// const oauth = await fetch(VoxeetSecret.validateURL, {
// method: 'POST',
// headers,
// body: JSON.stringify({
// grant_type: 'client_credentials',
// }),
// })
// .then((oauthResponse) => oauthResponse.json())
// .catch((err) => res.status(500).send(err));
// if (oauth) res.status(200).send(oauth);
};