【问题标题】:Insert event in google calendar using service account with Nodejs使用 Nodejs 的服务帐户在谷歌日历中插入事件
【发布时间】:2020-05-25 05:23:32
【问题描述】:

我无法通过服务帐户使用 Nodejs 插入事件。 服务帐户电子邮件已添加到具有更改事件权限的帐户中 我的 nodejs 代码在谷歌云功能上运行 这是我的代码:

const {
  google
} = require('googleapis');


var event = {
  'summary': 'Google I/O 2015',
  'location': '800 Howard St., San Francisco, CA 94103',
  'description': 'A chance to hear more about Google\'s developer products.',
  'start': {
    'dateTime': '2020-02-10T13:00:00-05:00'
  },
  'end': {
    'dateTime': '2020-02-10T15:00:00-05:00'
  },
  'attendees': [{
    'email': 'Emailh@domain.com'
  }],
  'reminders': {
    'useDefault': false,
    'overrides': [{
        'method': 'email',
        'minutes': 24 * 60
      },
      {
        'method': 'popup',
        'minutes': 10
      },
    ],
  },
};

exports.helloWorld = (req, res) => {
  google.auth.getClient({
    scopes: 'https://www.googleapis.com/auth/calendar',
  }).then(auth => {
    const calendar = google.calendar({
      version: 'v3',
      auth
    });
    calendar.events.insert({
      auth: auth,
      calendarId: 'MyCalendarID',
      resources: event,
    }, function(err, event) {
      if (err) {
        console.log('There was an error contacting the Calendar service: ' + err);
        return;
      }
      console.log('Event created: %s', event.htmlLink);
    });
  })

};

当我使用读取函数时,相同的代码可以正常工作。 有什么想法吗?

【问题讨论】:

标签: node.js google-cloud-functions google-calendar-api service-accounts


【解决方案1】:

这是一个已知的错误

使用服务帐户将与会者添加到活动时,会出现issue

当前的解决方法是冒充使用G Suite Domain-wide Delegation 的用户。如果这样做,您应该能够创建与参与者一起的活动。

另一种选择是从活动创建请求中删除参与者。

【讨论】:

  • 你是最棒的,我已经删除了与会者,它有效!但我仍然没有参加者,这并不性感。谷歌应该努力解决这个问题。
  • 任何看到此问题的人,我建议您为该问题加注星标,以鼓励 Google 尽快修复它!
猜你喜欢
  • 2016-09-30
  • 1970-01-01
  • 1970-01-01
  • 2017-12-24
  • 2019-06-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-10
相关资源
最近更新 更多