Guides

How to Set Up a Google Service Account for WordPress (Step by Step)

A Google service account is what allows a WordPress plugin to talk to Google Calendar without anyone needing to log in. Here is exactly how to create one.

15 April 2026  ·  7 min read
How to Set Up a Google Service Account for WordPress (Step by Step)

If you are setting up a WordPress plugin that connects to Google Calendar — or any other Google API — you will likely need a service account. A service account is a special credential that lets a server-side application communicate with Google’s APIs without requiring a person to log in through a browser.

This guide covers the complete setup from scratch: creating a Google Cloud project, enabling the API you need, creating the service account, and downloading the JSON key file. The whole process takes about 15 minutes.

What is a Google service account?

A regular Google account belongs to a person and is authenticated by a username and password (or OAuth). A service account belongs to an application. Instead of logging in, the application uses a private key file — a JSON file you download from Google Cloud Console — to prove its identity.

For WordPress booking plugins, the service account approach has a significant advantage over OAuth: it never expires. OAuth tokens time out and require re-authorisation. A service account key stays valid until you revoke it manually, which means your plugin keeps working without any periodic maintenance.

What you will need

  • A Google account (any Gmail or Google Workspace account)
  • Access to Google Cloud Console — free at console.cloud.google.com
  • WordPress Plugin (CalNative Booking)
  • About 15 minutes

No billing setup is required. The Google Calendar API is free within its standard usage limits, which are far higher than any booking plugin will ever reach.

Step 1: Go to Google Cloud Console

Open your browser and go to console.cloud.google.com. Sign in with your Google account if prompted.

If this is your first time using Google Cloud Console, you may be asked to agree to terms of service. Accept them to continue. You do not need to set up billing for the Google Calendar API.

Step 2: Create a new project

A Google Cloud project is the container that holds your APIs and credentials. You need one project per application — or in this case, one for your booking plugin.

  • At the top of the page, click the project selector dropdown (it shows the current project name or “Select a project”)
  • In the popup, click New Project in the top right corner
  • Enter a project name — something like wordpress-booking or my-calendar-plugin
  • Leave the organisation field as-is and click Create

The project takes a few seconds to create. Once it’s ready, make sure it is selected in the project selector before continuing — all the steps below must be done inside this project.

Step 3: Enable the Google Calendar API

New projects start with no APIs enabled. You need to explicitly turn on each API your application will use.

  • In the left navigation, go to APIs & Services → Library
  • In the search box, type Google Calendar API
  • Click the Google Calendar API result
  • Click Enable

The page will refresh and show the API dashboard. You will see a message confirming the API is now enabled. You can ignore the “Create Credentials” prompt on this page — you will create them in the next step.

Step 4: Create a service account

Now you will create the service account that your plugin will use to authenticate.

  • Go to APIs & Services → Credentials
  • Click + Create Credentials at the top of the page
  • Choose Service account from the dropdown

You will see a three-step form:

Step 1 — Service account details:

  • Enter a Service account name — for example booking-plugin. Google will generate the account ID automatically.
  • Add a description if you like — for example “Used by the WordPress booking plugin to access Google Calendar”
  • Click Create and Continue

Step 2 — Grant this service account access to the project:

  • You can skip this step — click Continue

Step 3 — Grant users access to this service account:

  • Skip this step too — click Done

The service account is now created. You will be taken back to the Credentials page where it appears under the Service Accounts section. Copy the service account email address — it looks like booking-plugin@your-project-id.iam.gserviceaccount.com. You will need it in a later step.

Step 5: Create and download the JSON key

The JSON key file is what your WordPress plugin uses to prove it is the service account. You download it once — Google will not let you download it again, so keep it safe.

  • On the Credentials page, click the email address of the service account you just created
  • Go to the Keys tab
  • Click Add Key → Create new key
  • Select JSON as the key type
  • Click Create

A .json file will download to your computer immediately. This is your service account key. Treat it like a password:

  • Do not share it publicly
  • Do not commit it to a Git repository
  • Do not upload it to a publicly accessible folder on your server

The plugin settings page will ask you to upload this file — it stores it securely on your server, outside the webroot.

Step 6: Share your Google Calendar with the service account

The service account now exists, but it does not yet have access to your calendar. You need to share the specific calendar with it — just like you would share a calendar with a colleague.

  • Open Google Calendar at calendar.google.com
  • In the left sidebar, find the calendar you want to use for bookings
  • Click the three-dot menu (⋮) next to the calendar name
  • Choose Settings and sharing
  • Scroll down to Share with specific people or groups
  • Click Add people and groups
  • Paste the service account email address from Step 4
  • Set the permission to Make changes to events
  • Click Send

The “Make changes to events” permission is necessary because the plugin needs to both read availability (free/busy data) and write new events when a booking is confirmed. “See all event details” alone is not enough.

Step 7: Find your Calendar ID

Your plugin settings will ask for your Calendar ID — a unique identifier for the specific calendar you want to use. While you are in the calendar settings page from Step 6:

  • Scroll down to the Integrate calendar section
  • Copy the Calendar ID shown there

For your primary Google Calendar, the Calendar ID is simply your Gmail address — for example yourname@gmail.com. For other calendars you have created, it is a longer string ending in @group.calendar.google.com.

Step 8: Upload to your WordPress plugin

You now have everything you need:

  • The JSON key file
  • The Calendar ID

In your WordPress admin, go to Settings → CalNative Booking. Paste your Calendar ID into the Calendar ID field and upload the JSON key file. Save your settings.

The plugin will immediately begin reading your calendar’s free/busy data. Open your booking page — you should see available slots based on your working hours and your current calendar events.

Troubleshooting common issues

The booking widget shows no available slots. Check that the Calendar ID is correct and that you shared the calendar with the service account email — not the project ID. Also confirm the Google Calendar API is enabled in your project (Step 3).

An existing event is not being blocked. The event must be on the calendar whose ID you entered in the plugin. Events on other calendars on your Google account are not checked by default. To block time based on other calendars, add them as additional calendars within the same Google account, or create a blocking event on your booking calendar manually.

The plugin says the JSON key is invalid. Make sure you are uploading the file exactly as downloaded — do not open or edit it. If you accidentally edited it, delete the key from Google Cloud Console (Credentials → Keys tab → Delete) and create a new one.

You see a permission error in the plugin. The service account was shared with the calendar, but with the wrong permission level. Go back to the calendar’s sharing settings, find the service account email, and change the permission to Make changes to events.

How long does the setup last?

Service account credentials do not expire. Once you complete this setup, it works indefinitely. You do not need to reconnect, refresh tokens, or revisit Google Cloud Console unless you deliberately rotate or revoke the key.

This is the main practical advantage over OAuth-based integrations — there is no maintenance burden after the initial setup.

Back to Blog