我一直致力于在我的 Web 应用程序中集成 Zoom 视频会议 API。通过使用 OAuth 并将我的应用程序授权给 Zoom,我获得了一个授权码,可用于从 Zoom 获取访问令牌以进行后续 API 请求。我正在根据此文档向https://zoom.us/oauth/token端点发送节点请求以获取访问令牌。
我不知道他们为什么将zoomcallback
其用作端点。以下是发送请求以获取访问令牌的代码:
router.get('/zoomcallback', function(req, res) {
const zoomtokenep = "https://zoom.us/oauth/token";
const myappredirect = "https://myapp.io/zoomcallback";
if (req.query.code) {
var auth = "Basic " + new Buffer(zoomclientid + ':' +
zoomclientsec).toString('base64');
var url = zoomtokenep + '?grant_type=authorization_code&code=' +
req.query.code + '&redirect_uri=' + myappredirect;
request.post({
url: url,
headers: {
"Authorization": auth
}
}, function(error, response, body) {
if (error) {
console.log("Error when getting Zoom token = " + error);
return;
}
body = JSON.parse(body);
if (body.access_token) {
accessToken = body.access_token;
refreshToken = body.refresh_token;
// Process and securely store these tokens
} else {
console.log("FATAL - could not get zoom token");
}
return;
});
} else {
console.log("Missing code from Zoom");
}
});
这是对此请求的成功响应:
{
"access_token": "5kwaMOrdEFWx1jYVK8qg80cImPYBA83Zff",
"token_type": "bearer",
"refresh_token": "Ggf2816C5ANa6XVplzO8vwE6IRIXtjvE",
"expires_in": 3599,
"scope": "meeting:write user:read recording:write webinar:write"
}