belladonna
belladonna

Reputation: 31

How to make changes to a single user's google calendar using google apps script

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.

Upvotes: 0

Views: 200

Answers (1)

Dmitry Kostyuk
Dmitry Kostyuk

Reputation: 1459

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

Upvotes: 1

Related Questions