4

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?
Andrew Hubbs
  • 9,338
  • 9
  • 48
  • 71

1 Answers1

2

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.

AleJacquet
  • 161
  • 1
  • 8
  • I see in the docs that one of the possible GTLRCalendar_AclRule_Scope options is "domain". So maybe it's somehow possible to get invitations to the calendar for all users in the domain? – Vitya Shurapov Jun 14 '19 at 14:36