21 lines
655 B
JavaScript
21 lines
655 B
JavaScript
const VoxeetSecret = require('../VoxeetSecret.json');
|
|
module.exports = async (req, res) => {
|
|
const { key, secret } = VoxeetSecret;
|
|
const credentials = btoa(encodeURI(key) + ':' + encodeURI(secret));
|
|
const headers = {
|
|
'Content-Type': 'application/json',
|
|
'Cache-Control': 'no-cache',
|
|
Authorization: 'Basic ' + credentials,
|
|
};
|
|
const oauth = await fetch(VoxeetSecret.refreshURL, {
|
|
method: 'POST',
|
|
headers,
|
|
body: JSON.stringify({
|
|
refresh_token: req.params.token,
|
|
}),
|
|
})
|
|
.then((oauthResponse) => oauthResponse.json())
|
|
.catch((err) => res.status(500).send(err));
|
|
if (oauth) res.status(200).send(oauth);
|
|
};
|