【发布时间】:2022-07-07 00:47:57
【问题描述】:
我已经设法使用 Node.Js 库 googleapis(更多信息 here)来创建 google 日历事件。我正在使用服务帐户并将相关详细信息传递给 auth 函数以获取 JWT 令牌:
const auth = new google.auth.JWT(
CREDENTIALS.client_email,
null,
CREDENTIALS.private_key,
SCOPES,
"email@domain.com"
);
注意:“email@domain.com”帐户实际上是一个 google 帐户,但出于安全考虑,我在此帖子中使用了别名。
然后我使用 auth 变量将事件插入日历。我传递给插入函数的资源正在使用docs 中提到的属性:
let event = {
summary: ...,
location: ...,
description: ...,
start: {
dateTime: ...,
timeZone: ...,
},
end: {
dateTime: ...,
timeZone: ...,
},
attendees: [
{
email: ...,
}
],
guestsCanSeeOtherGuests: false,
guestsCanInviteOthers: false,
creator: {
displayName: "Creator Name",
self: true
},
organizer: {
displayName: "Organizer Name"
}
};
事件是按我的意愿创建的,但似乎没有应用组织者和创建者属性。电子邮件邀请就像来自“email@domain.com”帐户一样到达。
我发现我可以通过更改 UI 上的日历名称来更改组织者的名称,但以编程方式似乎不起作用。此外,创作者的名字不想让步。创建者的姓名始终显示为“电子邮件”或“电子邮件”。服务帐户冒充“email@domain.com”,所以我假设显示名称只是作为电子邮件的前半部分。
我已在 UI 上为“email@domain.com”帐户设置了名称,但该名称也未在电子邮件邀请中使用。服务帐户设置中似乎也没有任何内容可以更改此名称。
我做了一些研究,发现其他一些人也在为类似的事情苦苦挣扎:
- Change displayName of event creator in Google Calendar API PHP
- Google Calendar API v3 DisplayName
- Google Calendar API: Display Name doesn't work
似乎没有明确的答案,但是,如果有,但我只是错过了它,我很高兴被引导到正确的地方。
对此的任何帮助将不胜感激。
【问题讨论】:
标签: node.js google-api google-calendar-api google-api-nodejs-client