我需要一个带有Google日历API的 NodeJS 服务器来检索事件。
我正在使用google-calendar库和代码示例
var gcal = require('google-calendar');
var google_calendar = new gcal.GoogleCalendar(accessToken);
var GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
var passport = require('passport');
var gcal = require('google-calendar');
passport.use(new GoogleStrategy({
clientID: config.consumer_key,
clientSecret: config.consumer_secret,
callbackURL: "http://localhost:8082/auth/callback",
scope: ['openid', 'email', 'https://www.googleapis.com/auth/calendar']
},
function(accessToken, refreshToken, profile, done) {
google_calendar = new gcal.GoogleCalendar(accessToken);
console.log(google_calendar);
return done(null, profile);
}
));
我的config.js
文件如下:
var env = require('node-env-file');
env(__dirname + '/.env');
module.exports = {
consumer_key: process.env.GOOGLE_CONSUMER_KEY,
consumer_secret: process.env.GOOGLE_CONSUMER_SECRET,
}
然后我使用包含所有凭据的.env
文件:
SLACK_TOKEN = "xxxxxx"
GOOGLE_CONSUMER_KEY = "xxxxxx"
GOOGLE_CONSUMER_SECRET = "xxxxx"
这些凭据来自我下载的json
来自我的Google帐户设置Google日历API,如google-guide中所述。
现在,当我使用node index.js
命令运行脚本时,我没有得到任何输出:
节点index.js body - 解析器不推荐使用bodyParser:使用单独的json / urlencoded中间件index.js:37:13 body - parser deprecated undefined extended:提供扩展选项node_modules / body - parser / index.js:105:29 express - session deprecated undefined resave option; 提供resave选项index.js:38:13 express - session deprecated undefined saveUninitialized option; 提供saveUninitialized选项index.js:38:13
所以,显然没有console.log
输出。我错过了什么?