I'm designing a google apps script that is linked to a bot that needs to add and delete events to a specific user's calendar. I need to find a way to do this without giving edit access to all people with access to the script. I was thinking of using the calendar api but that uses oauth2.0. Is there a way to use an api key instead? Another option I was considering was using a service account with domain-wide delagation, but I don't if it's possible to do what I want with it. Any ideas would be helpful.
Asked
Active
Viewed 158 times
1 Answers
1
This is a little advanced, but fesable.
You need to use the Calendar API with a service account and domain-wide delegation and OAuth2. I have described the process in this story on Medium (make sure to read through all three examples), however the steps are pretty much as follows:
- Create a service account
- Download its JSON key
- Enable domain-wide delegation
- Impersonate a super-user
- Create token with OAuth2
- Send request to the Calendar API with
Bearer
token generated with OAuth2

Dmitry Kostyuk
- 1,354
- 1
- 5
- 21