使用服务帐户创建Google日历事件,可以更改创建者名称

发布于 2025-02-13 09:59:13 字数 2794 浏览 1 评论 0 原文

我设法使用了node.js库, googleapis href =“ https://developers.google.com/calendar/api/v3/reference/reference/events/insert#node.js” rel =“ nofollow noreferrer”>在此创建Google日历事件。我正在使用一个服务帐户并将相关详细信息传递到auth函数中以获取JWT令牌:

const auth = new google.auth.JWT(
    CREDENTIALS.client_email,
    null,
    CREDENTIALS.private_key,
    SCOPES,
    "[email protected]"
);

注意:“ [email 受保护] “帐户在事实是Google帐户,但我在此帖子上使用别名是出于安全目的。

然后,我使用auth变量将事件插入日历中。我传递到插入函数的资源是使用文档

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"
  }
};

该事件是根据我想要的,但是似乎没有应用组织者和创建者属性。该电子邮件邀请到达“ “ 帐户。

我发现我可以通过更改UI上日历的名称来更改组织者的名称,但是从编程上讲,它似乎行不通。此外,创作者的名字不想让人感到烦恼。创作者的名字总是以“电子邮件”或“电子邮件”的形式显示。该服务帐户正在模仿“ 显示名称只是被视为电子邮件的前半部分。

我已经在UI上设置了“ [emagy 帐户,但是电子邮件邀请中也没有使用此名称。在服务帐户设置中似乎没有任何东西可以更改此名称。

我做了一些研究,发现了其他一些人在类似事情上挣扎的人:

https://stackoverflow.com/questions/64972472/google-calendar-api-display-name-doesnt-work---但是,如果有的话,请做一个确定的答案,我只是错过了它,我很高兴能被指导到正确的位置。

对此的任何帮助将不胜感激。

I have managed to use the Node.Js library, googleapis (more information here) to create the google calendar event. I am using a service account and passing the relevant details into the auth function to get a JWT token:

const auth = new google.auth.JWT(
    CREDENTIALS.client_email,
    null,
    CREDENTIALS.private_key,
    SCOPES,
    "[email protected]"
);

Note: the "[email protected]" account is in fact a google account, but I'm using an alias on this post for security purposes.

I am then using the auth variable to insert the event into the calendar. The resource I pass into the insert function is using the properties as mentioned on the 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"
  }
};

The event is created as I want, but neither the organizer nor creator properties seem to be applied. The email invite arrives as if it would arrive from the "[email protected]" account.

I have spotted I can change the organizer's name by changing the calendar's name on the UI, but programmatically it doesn't seem to work. Furthermore, the creator's name doesn't want to budge. The creator's name always shows up as "email" or "Email". The service account is impersonating "[email protected]", so I assume the display name is just being taken as the first half of the email.

I have set the name on the UI for the "[email protected]" account, but this name is not used in the email invitation either. There doesn't seem to be anything in the service account settings either to change this name.

I have done a bit of research and found some other people who struggled with similar things:

There doesn't seem to be a definitive answer, however, if there is, and I've just missed it, I am happy to be guided to the right place.

Any help on this would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沒落の蓅哖 2025-02-20 09:59:13

很久以前,我也有一个类似的问题, creator.displayname 文档仅表示会显示如果可用,这是令人困惑的。

之后,我找到了此Google 问题跟踪器,提到“如果有的话”是引用的。到Google+个人资料信息。我更新了Google+内的名称,并且可以使用。由于Google+不再可用,我会说尝试使用 currents (哪个(哪个)替换了Google+),它应该做同样的事情。

您可以访问电流在这里

参考:

I had a similar issue a long time ago, and the creator.displayName documentation only stated that it would show if available, which was confusing.

After that, I found this Google issue tracker, which mentioned that the "if available" was referring to the Google+ profile information. I updated the name inside Google+, and it worked. Since Google+ is no longer available, I will say to try using Currents (which replaced Google+), and it should do the same thing.

You can access Currents here.

Reference:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文