packages/features/delegation-credentials/README.md
Step 0: Create a Workspace Platform(to be done once for the Cal.com instance, by the Cal.com instance admin)
Step 1: Create a Google Cloud Project or use existing one(to be done once for the Cal.com instance)
Before you can create a service account, you'll need to set up a Google Cloud project.
Step 2: Create a Service Account in Google Cloud Console(to be done for every organization)
A service account is needed to act on behalf of users
Step 3: Create Delegation Credential(To Be taken by Cal.com instance admin):
Impersonate the organization owner and go to https://app.cal.com/settings/organizations/delegation-credential to create a Delegation Credential
Step 4: Copy the Client ID and OAuth Scope (To Be Taken By Cal.com organization Owner/Admin in Cal.com):
Step 5: Add Client ID under Domain-Wide Delegation (To Be taken By Google Workspace Admin):
https://www.googleapis.com/auth/calendarStep 6: Enable Delegation Credential(To Be taken By Cal.com organization Owner/Admin in Cal.com):
Cron jobs ensure that for each and every member of the organization that has Delegation Credential enabled, corresponding SelectedCalendar records are there. These crons currently run every 5 minutes and process a batch in one run to avoid overloading the DB and third party CalendarAPIs, look at vercel.json for the up-to-date schedule.
credentials cron job creates Delegation User Credential records for all the members of the organization who don't have Delegation User Credentials yet. It also ensures that on disabling Delegation Credential, the Delegation User Credentials are deleted which automatically deletes the SelectedCalendar and CalendarCache records through DB cascade.selected-calendars cron job creates SelectedCalendar records for all the Delegation User Credentials of the organization who don't have Selected Calendars yet.