Very rudimentary development version of zoom auth #5

pull/277/head
nicolas 2021-06-11 02:10:56 +02:00
parent 615e59cde7
commit 65a029acde
1 changed files with 11 additions and 14 deletions

View File

@ -18,21 +18,18 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const authUrl = 'https://zoom.us/oauth/authorize?response_type=code&client_id=' + client_id + '&redirect_uri=' + redirectUri;
const authHeader = 'Basic ' + Buffer.from(client_id + ':' + client_secret).toString('base64');
// Convert to token
const options = {
method: 'POST',
body: {
grant_type: 'authorization_code',
code,
redirect_uri: authUrl
},
headers: {
Authorization: authHeader
}
};
return new Promise( async (resolve, reject) => {
const result = await fetch('https://zoom.us/oauth/token', options)
const result = await fetch('https://zoom.us/oauth/token', {
method: 'POST',
body: JSON.stringify({
grant_type: 'authorization_code',
code,
redirect_uri: authUrl
}),
headers: {
Authorization: authHeader
}
})
.then(res => res.text());
console.log(result);