Google Service Account Setup

Step-by-step guide to creating a Google Service Account and obtaining the JSON credentials file for Google Calendar integration.


What is a Service Account?

A Google Service Account is a special type of account used by applications (not humans) to access Google APIs like Google Calendar. It allows your website to read and write calendar events programmatically.

Setup Steps

1. Create a Google Cloud Project

Go to Google Cloud Console

Click Select a project at the top → New Project

Name it something like "My Website Bookings" and click Create

2. Enable Google Calendar API

In the sidebar, go to APIs & Services → Library

Search for "Google Calendar API"

Click on it and press Enable

3. Create Service Account

Go to IAM & Admin → Service Accounts

Click Create Service Account

Enter a name (e.g., "calendar-booking") and description

Click Create and Continue

Skip the optional steps (Grant access, Grant users access) and click Done

4. Generate JSON Key

Find your newly created service account in the list

Click the ⋮ (three dots)Manage keys

Click Add Key → Create new key

Select JSON and click Create

A JSON file will download automatically - keep this safe!

5. Share Calendar with Service Account

Open the JSON file and copy the "client_email" value (looks like: your-service@project-id.iam.gserviceaccount.com)

Go to Google Calendar

Find your calendar in the left sidebar → click ⋮ → Settings and sharing

Scroll to Share with specific people

Click Add people and paste the service account email

Set permission to Make changes to events

6. Get Calendar ID

Still in Calendar Settings, scroll to "Integrate calendar"

Copy the Calendar ID (looks like: abc123@group.calendar.google.com)

7. Provide to Developer

Send your developer:

• The JSON credentials file

• The Calendar ID

They will add these as environment variables:

  • # The entire JSON file content (as a single-line string)
    GOOGLE_SERVICE_ACCOUNT_JSON='{"type":"service_account","project_id":"...",...}'
    
    # Your calendar ID
    GOOGLE_CALENDAR_ID=abc123@group.calendar.google.com

    Security Best Practices

    Never commit the JSON file to Git!

    Store it securely and only share via secure channels (password manager, encrypted email)

    Only grant "Make changes to events" permission, not "Make changes AND manage sharing"

    If compromised, delete the key in Google Cloud Console and generate a new one

    Google Cloud Console

    Service Accounts

    Google Calendar