Very rudimentary development version of zoom auth #5
This commit is contained in:
parent
615e59cde7
commit
65a029acde
1 changed files with 11 additions and 14 deletions
|
@ -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 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');
|
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) => {
|
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());
|
.then(res => res.text());
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue