Node.js Google Cal API插入404错误

Node.js Google Cal API插入404错误,node.js,google-api,google-calendar-api,Node.js,Google Api,Google Calendar Api,我一直在尝试使用google api在日历中添加,但我发现了一个神秘的错误: errors: [{ domain: 'global', reason: 'notFound', message: 'Not Found'}], code: 404, message: 'not Found'} 似乎我没有访问文件的权限,但我不确定是哪个文件 以下是post请求中的代码位 谷歌日历是谷歌日历npm模块。 req.user是已登录的用户 var eventBody = { 'status':'c

我一直在尝试使用google api在日历中添加,但我发现了一个神秘的错误:

errors: [{ domain: 'global', reason: 'notFound', message: 'Not Found'}], code: 404, message: 'not Found'}
似乎我没有访问文件的权限,但我不确定是哪个文件

以下是post请求中的代码位

谷歌日历
是谷歌日历npm模块。
req.user
是已登录的用户

var eventBody = {
    'status':'confirmed',
    'summary': "Test summary of event",
    'description': "COME BY AND HAVE A LOT OF FUN DESCRIPTION",
    'start': {
      'dateTime': moment(new Date(1424484000000)).format("YYYY-MM-DDTHH:mm:ssZ"),
      'timeZone': "America/New_York"
    },
    'end': {
      'dateTime': moment(new Date(1424491200000)).format("YYYY-MM-DDTHH:mm:ssZ"),
      'timeZone': "America/New_York"
    },
    'attendees': [
        {
          'email': req.user.googleId.email,
          'responseStatus': 'needsAction'
        }
    ]
  };
  var google_calendar = new googleCal.GoogleCalendar(req.user.googleId.token);
  google_calendar.events.insert(req.user.googleId.id, eventBody, function(err, response){
    console.log("Google response:", err, response);

    if (!err){
      res.send(200, response);
    }
    else {
      res.send(400, err);
    }
  });
我已经包括了访问令牌、用户ID(从oauth返回的google配置文件中获取)和电子邮件地址。我仍然不确定为什么没有访问权限(如果有什么不同的话,我正在使用.edu gmail帐户…)

这是我使用passport.js的OAUth代码

passport.use(new GoogleStrategy({
  clientID: googleAuth.clientID,
  clientSecret: googleAuth.clientSecret,
  callbackURL: googleAuth.callbackURL
}, function(token, params, profile, done){
  process.nextTick(function(){
    User.findOne({'googleId.id': profile.id}, function(err, appUser){
      if (err) return done(err);
      if (appUser){
        console.log("Params",params);
        console.log("Profile", profile);
       appUser.googleId.token = token;
       appUser.lastTime = new Date();
       return done(null, appUser);
     } 

    else 
    {
      var newUser = new User();
      newUser.googleId.id = profile.id;
      newUser.googleId.token = token;
      newUser.googleId.name  = profile.displayName;
      newUser.lastTime = new Date();
      newUser.googleId.email = profile.emails[0].value;
      newUser.save(function(err){
        if (err) throw err;
        return done(null, newUser);
      });
    }
  });
  });
}));

非常感谢您的帮助

我会做一个日历列表,以获取您的认证用户日历列表。通过这种方式,您可以确保您可以访问上述日历。你确定(req.user.googleId.id)是日历id吗?还要添加OAuth代码。问题应该可以测试。我不完全确定这一部分,也许我抓到的东西不是日历ID,我会更新它。如果是这样的话,我从哪里获取calendarId?Calendar list返回用户日历的列表哦,看来我应该获取用户日历并将其用于ID?是的,您只能获取公共日历和用户拥有的日历。你不能只写任何日历。