Google Calendar JavaScript api,使用“ write”将用户添加到日历中。访问 [英] Google Calendar JavaScript api, add user to a calendar with "write" access

查看:109
本文介绍了Google Calendar JavaScript api,使用“ write”将用户添加到日历中。访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个与Google日历关联的网站。该网站使用Google的JavaScript API检索公共日历的事件并将其呈现在网站上。现在,我可以创建新事件,更新事件并从我的站点中删除事件,并且可以在Google日历中进行更新了。

I'm developing a site connected with Google Calendar. This site uses Google's JavaScript API to retrieve events of a public calendar and render them on the website. I'm now able to create new events, update events and remove events from my site and be updated with no problem in the Google Calendar.

如果我能够编辑此日历信息是因为我的Google帐户对此特定日历具有读/写权限。

If I'm able to edit this calendar information is because my Google account has read/write permission on this particular calendar.

我的问题:是否可以将用户添加到列表中显然,我不想在日历设置页面上手动添加每个帐户的电子邮件。

My question: is there a way to add users to the list of accounts that have writing permission for this calendar using the JavaScript API? Obviously I don't want to manually add the emails of each account on the calendar settings page.

我该怎么办?我是否需要插入ACL规则(关于JavaScript的文档很少)或类似的东西?

What can I do? Do I need to make an ACL rule insert (not much documentation on this for JavaScript) or something like that?

推荐答案

使用< a href = https://developers.google.com/google-apps/calendar/v3/reference/acl/insert rel = nofollow noreferrer> Acl:插入您可以使用 writer添加用户或所有者权限,授予用户对您日历的读写权限。

Using Acl: insert you can add a user with "writer" or "owner" permissions, which grant the user read and write permissions to your calendar.


分配给合并范围的角色。可能的值为:

The role assigned to the scope. Possible values are:


  • 无-不提供访问权限。

  • freeBusyReader-提供对忙/闲信息的读取权限。

  • 阅读器-提供对日历的读取权限。具有读者访问权限的用户将看到
    私人活动,但活动详细信息将被隐藏。

  • 作家-提供对日历的读写权限。私人活动将向具有作者访问权限的用户显示,并且活动详细信息将显示

  • 所有者-提供日历的所有权。该角色具有作家角色的所有权限,并具有查看
    和操纵ACL的附加功能。

  • "none" - Provides no access.
  • "freeBusyReader" - Provides read access to free/busy information.
  • "reader" - Provides read access to the calendar. Private events will appear to users with reader access, but event details will be hidden.
  • "writer" - Provides read and write access to the calendar. Private events will appear to users with writer access, and event details will be visible.
  • "owner" - Provides ownership of the calendar. This role has all of the permissions of the writer role with the additional ability to see and manipulate ACLs.

使用同一页面上的API Explorer,我能够成功发出此请求:

Using the API Explorer on that same page I was able to successfully make this request:

POST https://www.googleapis.com/calendar/v3/calendars/12345@group.calendar.google.com/acl?key={YOUR_API_KEY}

{
 "role": "writer",
 "scope": {
  "type": "user",
  "value": "user@example.com"
 }
}

您可以将其与Google API Javascript客户端一起使用,如下所示:

You can use it with the Google API Javascript client like this:

var calendarid = "12345@group.calendar.google.com";
var req = {
  "calendarId": calendarid,
  "resource": {
    "role": "writer",
    "scope": {
      "type": "user",
      "value": "user@example.com"
    }
  }
}
var request = gapi.client.calendar.acl.insert(req);
request.execute(function(resp) {
  console.log(resp);
});

这篇关于Google Calendar JavaScript api,使用“ write”将用户添加到日历中。访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆