I am working on a web application where you can basically create event and join events of others people.
When people log in, they can link their accounts with their Google Agenda.
When people are doing some updates from my app, everything is ok. But not, when they do it from their Google Agenda account.
So, I would like to find a way to update the events on my app when users are editing the event directly from their Google Agenda.
I have thought of doing it in the following way but I don't know if it is possible :
- create a Service Account which has a specific mail address (let's call it [email protected])
- each time an event is created on my web app, the email [email protected] also receive the event
- in that way, each time the organizer change the event (date, location, or delete it), the [email protected] receive the information (mail with new ICS)
- then, i would send the information on my web app to change the event accordingly
Is it possible to do it that way ? I know I could also create an Chrome Extension or a Google Calendar Add-On, but with the way I just described I was thinking also doing it for the Outlook Calendar.
Thank you for your advices
CodePudding user response:
It's hard to address this without knowing exactly how your application works or what exactly you are seeking (documentation sources? code samples?), but here's some general advice:
- Your example with the service account can work. If the service account is already a guest then you can just watch the service account's calendar with
events.list
and keep your application updated. The problem is that your application won't be able to make changes to the event unless all other guests can make changes too. This may or may not matter to you but there's also already a better way to handle this. - You said that your app requests access to the users' Calendars. If you request offline access then you can keep track of the changes on their Calendars by syncing them periodically with your app. You tagged this as "Google Apps Script" so you could check out this library to request OAuth offline access. I would say that this is the best approach because after the users grant access to the app you can just keep it in sync and make changes to the events on their behalf as well. One possible issue is that if you don't want your app to show events that were not created in it, then you'll have to figure out a way to keep track of your events to filter out the rest.
- One last option could be to use the service account's calendar as the main calendar where the events are created, then either only allow users to make changes from your app, or give all guests access to edit the event freely. This way you also only need to watch the service account's calendar to keep in sync.
- I'm not familiar with Outlook but they have a Calendar API as well which I would expect to work in a similar way. If you don't want to have to handle two APIs I guess the service account method would work with both at the same time, but it's still not ideal.