How do you add a Google Calendar to all users for a domain?

吃可爱长大的小学妹 提交于 2019-12-07 12:37:21

问题


I am having trouble figuring out how to add a calendar to all of a domain's users' CalendarList.

So far I can successfully create the Calendar and create a domain wide ACL but I don't know how to insert the calendar into domain users' lists.

Using the ruby client API it looks something like this:

client = Google::APIClient.new
service = client.discovered_api("calendar", "v3")

calendar_response = JSON.parse(client.execute(:api_method => service.calendars.insert,
  :body => JSON.dump({"summary" => "events"}),
  :headers => { "Content-Type" => "application/json" }).response.body)

rule = {
  "scope" => {
    "type" => "domain",
    "value" => domain,
  },
  "role" => "writer"
}
acl_result = client.execute(:api_method => service.acl.insert,
  :parameters => { "calendarId" => calendar_response["id"] },
  :body => JSON.dump(rule),
  :headers => { "Content-Type" => "application/json" })

This all works fine. It creates the calendar and it is shared with everyone in the domain. What I can't figure out is how to explicitly added it to the users' list of Calendars.

To add to the single authed user's calendar list would look like this:

list_params = {
  "calendarId" => calendar_response["id"],
  "hidden" => false,
  "selected" => true
}
calendar_list_result = client.execute(:api_method => service.calendar_list.insert,
  :body => JSON.dump(list_params),
  :headers => { "Content-Type" => "application/json" })

Questions:

  • If I am authenticated as a domain admin, can I create CalendarList item for all users?
  • If so, can it be done with a single command or do I need to make a call with every user id?
  • If I need to do a command for each user, how do I get the user ids?

回答1:


If I am authenticated as a domain admin, can I create CalendarList item for all users? No you can't :(.

If so, can it be done with a single command or do I need to make a call with every user id? You have to make a call for each user id.

If I need to do a command for each user, how do I get the user ids? To retrieve the user id you first must list all the users in the domain with the Admin SDK API, https://developers.google.com/admin-sdk/directory/v1/guides/manage-users#get_all_domain_users , then for each INSERT command in the calendar you change the user id, for the email address.



来源:https://stackoverflow.com/questions/15146146/how-do-you-add-a-google-calendar-to-all-users-for-a-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!