Google Calendar
Easy Services Booking can sync each resource with one of your Google calendars:
- To Google. New and changed bookings are added to the resource's Google calendar. Cancelled bookings are removed.
- From Google. Events you add in that Google calendar block the same time in Easy Services Booking, so clients cannot book it.
Easy Services Booking connects to one Google account with OAuth. All resources use that account, each with its own calendar.
Part 1: create a Google OAuth client (once)
-
Open the Google Cloud Console (console.cloud.google.com) and create a project, or pick one you have.
-
Go to APIs & Services > Library, search for Google Calendar API and click Enable.
-
Go to APIs & Services > OAuth consent screen and fill it in. Add the Google account that owns the calendars as a user if the app is in testing.
-
Go to APIs & Services > Credentials > Create credentials > OAuth client ID and choose Web application.
-
Under Authorized redirect URIs, add:
https://www.example.com/administrator/index.php?option=com_easyservicesbooking&task=configuration.googleredirectUse your own domain, and the folder if Joomla is in one. The exact URI is shown on the Google Calendar Settings tab of the Configuration page until you link an account.
-
Click Create and copy the Client ID and the Client Secret.
While the OAuth app is in testing, Google ends its tokens after a few days and you must link again. Publish the app on the consent screen to avoid this.
Part 2: link the Google account
- In Easy Services Booking, click Options, open Google Client Details, paste the Client ID and Client Secret, and save.
- Go to Configuration and open Google Calendar Settings.
- Set Enable Google Calendar Integration to Yes.
- Set Sync Forward Events, for example Three Months, and Sync Google events to Easy Services Booking? to Yes if Google events should block time.
- Enter a Google Cal Sync Secret: a long random text, letters and numbers only. Leave Google Query Max Results at 500 unless you have more events than that in the sync period.
- Click Save.
- Click Link this Calendar. Sign in to Google and allow access to your calendars. You return to the Configuration page with the message "Token code successfully extracted !" and the tab says Calendar is linked.
If the tab says Calendar is not linked correctly, Google did not send a refresh token. Remove the app's access at myaccount.google.com/permissions, then click ReLink this Calendar.
Part 3: connect each resource
- Go to Resources and open a resource.
- Under Calendar Integration Options, set Enable Google Calendar Integration to Yes.
- In Calendar Id, choose the Google calendar for this resource. The list shows the calendars of the linked account. It is empty until Part 2 is done.
- Save. Repeat for each resource.
Use a separate Google calendar for each resource, so their events do not block each other.
Part 4: turn on the sync
- Go to System > Manage > Plugins, search for Easy Services Booking - Sync Events Plugin and enable it. It is installed disabled. Without it, bookings are not sent to Google.
- Create a cron job that calls Your Google Sync URL from the Google Calendar Settings tab every 5 to 15 minutes. See Cron jobs or EasyCron.
Open the sync URL in your browser once to test it. It lists each step, such as "External event created succesfully".
What is synced
- Each time a booking is saved (created, confirmed, changed, cancelled) it joins the sync queue. The next sync sends it to Google. Pending bookings are sent too.
- The Google event title is the booking title, see What the booking title shows. The description holds the booking details.
- Google events in the Sync Forward Events period become blocked time on the resource. They show in Manage Diaries and the Bookings list, cannot be edited there, and are removed when you delete them in Google.
- Only events with a start and end time are read. All-day events in Google are not read correctly in 6.2.3, so block whole days with a holiday instead.
- A booking removed with Delete in the Bookings list is not removed from Google. Cancel bookings, or delete them in Manage Diaries, so the Google event is removed too, or delete it in Google yourself.
Troubleshooting
| What you see | What to check |
|---|---|
| The Calendar Id list is empty | Client ID and secret are saved in Options, Enable Google Calendar Integration is Yes on the Configuration page, and the account is linked |
| "Invalid secret" | The cron URL's secret is not the Google Cal Sync Secret |
| "Sync not enabled" | Enable Google Calendar Integration is No on the Configuration page |
| "token is missing" or an email "Google Cal Sync Problems" | The account is not linked, or Google ended the token. Use Tools > Unlink Google Cal, then Link this Calendar again |
| Bookings do not reach Google | The Sync Events Plugin is enabled, the resource has a Calendar Id, and the cron job runs |
| One booking never reaches Google | A booking that failed once stays in the queue and is not tried again. Fix the cause, use Tools > Purge Sync Queue, then open and save the booking again |
redirect_uri_mismatch from Google |
The redirect URI in Google Cloud is not exactly the one shown on the Google Calendar Settings tab |