Search code examples
javascriptgoogle-oauthgoogle-calendar-api

Google - Fetch calendar events from users using service account


i've been digging for some days but i'm not getting the right answer and i'm getting confused, the more i read, me more confused. This is the situation

  • The feature needs to get user consent (client) and be able to fetch user's calendar events each some time, e.g 2 weeks (in server side) in a nextjs application

  • My company has a google service account

  • Users are normal google users

What i understood is :

  1. I need to configure google service account oauth and extract client_id and secret values to be able to create a consent auth that will allows users to give consent using calendar scope (pretty sure of this)

  2. I need to create google client programatically using google compute which will allow my account to fetch user calendar information (not sure here)

I've started from a POC using my own account in which i've been able to solve this using step 1) and redirecting from consent to an internal url that get users token and save it in database, after that, hitting and endpoint using the token from the database to fetch events.

But they told me that company need to use a service account and that confused me a lot.

i will appreciate any help.


Solution

  • lastly i make it work just configured oauth and linking my service-account with aws appflow service.

    Thanks for your help!