0

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.

belladonna
  • 31
  • 5

1 Answers1

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:

  1. Create a service account
  2. Download its JSON key
  3. Enable domain-wide delegation
  4. Impersonate a super-user
  5. Create token with OAuth2
  6. Send request to the Calendar API with Bearer token generated with OAuth2
Dmitry Kostyuk
  • 1,354
  • 1
  • 5
  • 21