How do I access other users calendars with google

2019-04-29 03:41发布

问题:

I am using the Google Calendar (v3) API, with google apps and am wanting to use a single oauth2 credential to determine what users are free/busy at any given point.

I am wanting to use this: https://developers.google.com/google-apps/calendar/v3/reference/freebusy/query

But to use this I need to get all the calendar ids for all the users. I cannot do this as the java client for the google calendar can only retrieve calendars of the user who owns the credential.

Note: I have access to all the users through the provisioning api.

Any help would be much appreciated as I am totally blocked by this.

回答1:

For primary calendars, the calendarId is the user's email address. The authenticated user will also need to have permission to access the calendar. If you're using the Provisioning API then I'll assume you are a super admin, and super admins can access every calendar on their domain.

The specific query you are trying to do takes a list of calendarIds to query as a JSON list. If you are only concerned about primary calendars, then set each user's email as an id like this:

"items": [
  {
    "id": "user1@example.com"
  },
  {
    "id": "user2@example.com"
  }
]


回答2:

It took me about a week to successfully integrate with Google Calendar. Maybe my experience will help: http://www.tqis.com/eloquency/googlecalendar.htm