4

I have configured in my google account application following CalDAV and Google Calendar API instructions.

As result I have turned on 2 APIs for my application

  • CalDAV API;
  • Google Calendar API (GC API).

I have created token to get access via my personal client to google calendar information. Using quick start guide I have loaded only my personal calendar events. I have investigated other java samples but I did not find how to load calendars of different users.

Is it possible to load someones calendar information via CalDAV\GC API with java client? Which clients information I should have got to load clients data (accept loginName)? Can I have a link to get more information about loading users' calendar events to view & manage its from external applications?

Sergii
  • 7,044
  • 14
  • 58
  • 116

1 Answers1

1

To get the other users Calendar Events, Note: You must be an authenticated user that has a permission to access the other calendar events. By using this Events: list you can try here to get the other users calendar event by passing the calendarId of the other user in the calendarId parameter.

There is a Java example code here that you can follow. The "primary" word here means that you will access your own calendar, just change it to the calendarId of the user to get its own calendar event.

If you want to list Google Calendar Events without the User Authentication, then this SO question can help you with that. It use a Service Account to access the other user calendar.

Hope it helps you.

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31
  • i'have a questions:
      - how I can be authenticated as user who has a permission to access the other calendar events (i have to use my local application)? - how i can know users `calendarId`? is it possible to load it in dynamic way (if i know users mail or login only)? - is it possible to improve samples to resolve my issue?
    I have checked [calendar cmd sample](https://github.com/google/google-api-java-client-samples/tree/master/calendar-cmdline-sample) and [oauth2 cmd sample](https://github.com/google/google-api-java-client-samples/tree/master/oauth2-cmdline-sample)?
    – Sergii Jan 15 '17 at 12:09
  • If i configured my application in google account (created `client_secrets.json` for registered project and APIs), how can I load here different users information if I use key for project connected to my account only? I red [this answer](http://stackoverflow.com/questions/7130648/get-user-info-via-google-api) but its not clear for me... – Sergii Jan 15 '17 at 12:32
  • Google provides [quickstart guide](https://developers.google.com/google-apps/calendar/quickstart/java). I tried it with some suggested changes (changed `primary` to other users calendar): --- Events events = service.events() // .list("primary") .list("i.vlasyuk@gmail.com") .setMaxResults(10) .setTimeMin(now) .setOrderBy("startTime") .setSingleEvents(true) .execute(); --- GoogleJsonResponseException: 404 Not Found {"code" : 404, "errors" : [ { ... } ], } – Sergii Jan 15 '17 at 14:05
  • The user 'calendarId' is most likely his gmail account. If you are not authenticated to view the user calendar, then use the [Service Account](https://developers.google.com/identity/protocols/OAuth2ServiceAccount). – KENdi Jan 17 '17 at 06:07
  • `Service Account` needs `G Suite Domain` account. I do not have any dedicated domains for research google integration, so i can not register my personal `G Suite` account. – Sergii Jan 18 '17 at 09:04
  • This other user must share the calendar with you if you want to be accessing it. Sharing is done either via the web interface or via the acl collection of the calendar API. Please check this: https://developers.google.com/google-apps/calendar/concepts/sharing – luc Jan 18 '17 at 11:18