Reputation: 352
I have been working on integrating Zoom video conferencing API in my web application. By using OAuth and authorizing my application to Zoom, I have got an authorization code which can be used to get access token from Zoom to make subsequent API requests. I am sending a node request to https://zoom.us/oauth/token endpoint according to this documentation for getting access token.
I don't have any idea why they are using zoomcallback
as their endpoint. Below is the code to send a request to get access token:
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");
}
});
This is the successful response against this request:
{
"access_token": "5kwaMOrdEFWx1jYVK8qg80cImPYBA83Zff",
"token_type": "bearer",
"refresh_token": "Ggf2816C5ANa6XVplzO8vwE6IRIXtjvE",
"expires_in": 3599,
"scope": "meeting:write user:read recording:write webinar:write"
}
Upvotes: 0
Views: 5616
Reputation: 12542
You are misunderstanding the flow here. The flow of any external auth provider is:
access code
.Now, Here, 2nd point is where the /zoomcallback
comes in. You need to set in your ZOOM dashboard where it will redirect. In the tutorial the provided /zoomcallback
but it may be anything.
Basically, you need a route where zoom will redirect TO, where you will get the auth token and use that in Apis.
Upvotes: 3