使用带有 Nodejs 的服务帐户在 google 日历中插入事件
Insert event in google calendar using service account with Nodejs
我无法通过服务帐户使用 Nodejs 插入事件。
服务帐户电子邮件已添加到具有更改事件权限的帐户中
我的 nodejs 代码是 运行 on google cloud functions
这是我的代码:
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);
});
})
};
当我使用函数 read 时,相同的代码工作正常。
有什么想法吗?
这是一个已知错误
使用服务帐户向活动添加与会者时出现 issue。
当前的解决方法是模拟 使用G Suite Domain-wide Delegation 的用户。如果这样做,您应该能够创建有与会者的活动。
另一种选择是从活动创建请求中删除与会者。
我无法通过服务帐户使用 Nodejs 插入事件。 服务帐户电子邮件已添加到具有更改事件权限的帐户中 我的 nodejs 代码是 运行 on google cloud functions 这是我的代码:
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);
});
})
};
当我使用函数 read 时,相同的代码工作正常。 有什么想法吗?
这是一个已知错误
使用服务帐户向活动添加与会者时出现 issue。
当前的解决方法是模拟 使用G Suite Domain-wide Delegation 的用户。如果这样做,您应该能够创建有与会者的活动。
另一种选择是从活动创建请求中删除与会者。