Have problem with nodejs when I'm running script
var client_id = '',
client_secret = '',
redirect_url = 'http://localhost:3000/oauth2callback';
var google = require('googleapis');
var opn = require('opn');
var express = require('express');
var moment = require('moment');
var OAuth2 = google.auth.OAuth2;
var calendar = google.calendar("v3");
var scopes = [
'https://wwww.googleapis.com/auth/calendar'
];
var oauth2Client = new OAuth2(
client_id,
client_secret,
redirect_url
);
var url = oauth2Client.generateAuthUrl({
access_type: 'offline',
scope: scopes
});
var server = express();
server.listen(3000, function() {
opn(url);
});
server.get('/oauth2callback', function (req, res) {
var code = req.query.code;
oauth2Client.getToken(code, function (err, tokens){
if (!err) {
oauth2Client.setCredentials(tokens);
google.options({
auth: oauth2Client
});
init();
}
});
res.send("<script> window.open(locationm '_self', ''); window.close();
</script>");
});
function init() {
console.log('init!');
}
Error message: "(node:380) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: spawn cmd.exe ENOENT"
So please help if you know hot to resolve it!
via JohnnyHardman
No comments:
Post a Comment