← Documentation

Google Calendar

Google Calendar needs no introduction, is the calendar. Google Calendar brings all of your calendars together in one place, so you can manage work, personal life, and everything in between.

The Google Calendar add-on allows you to synchronize WordPress posts with Google Calendar events to build online agendas and public calendars.

The add-on

The Google Calendar API is a RESTful interface that lets you read and modify calendars data. This API use the OAuth 2.0 protocol for authentication and authorization. To talk with this API the add-on implements a custom bridge class based on the generic REST bridge that requires OAuth credentials.

A Google Calendar bridge will convert your calendar events and meetings into WordPress posts.

With Posts Bridge introspection API you’ll be able to inspect spreadsheet fields to easily map them to your post fields and taxonomies.

How to use

The first step to use the add-on is to activate it on the add-ons table on the general settings tab.

Once activated, a new tab named Google Calendar will be visible on the settings page. If it’s your first time, it should looks like this:

Bridge set up

A Google Calendar bridge will require the following components:

1. Credential

The Calendar API implements the OAuth 2.0 schema to grant access to its resources. To solve this authentication requirement, the add-on requires you to register a OAuth type of credential with the credentials of an Google OAuht Client. Check out our tutorial about How to set up a new OAuth Client on Google Cloud Console.

Once you got the Client ID and Client secret of the Google OAuth client, you have to go to Settings > Posts Bridge > HTTP > Authentication and register a new authentication credential.

Select OAuth as the authentication schema and put the Client ID and Client Secret in the respective fields. For the Authorization URL, you have to set https://accounts.google.com/o/oauth2/v2 and for the Scope https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar.events.

Once registered, Posts Bridge will ask you to Authorize the new credential. Click on the button and a new browser’s tab will be opened asking you for the authorization to Posts Bridge to access your account data. Click on Accept and then you will be redirected again to the HTTP tab of the plugin settings page with your credential authorized.

2. Backend

To configure the Calendar API as a backend follow this steps:

  1. Register a new backend with a unique name (Google API, for example), and a URL with https://www.googleapis.com as value.
  2. Add Accept as an HTTP header with application/json as value.
  3. Select a OAuth credential you’ve configured on the previous step.

3. Post type

Posts Bridge allows you to bridge any registered post type from your WordPress site. If you’ve not registered it yet, you can register it with Posts Bridge. Go to the CPTs tab and create a new custom post type. The registration form will inherit the registration defaults, but you can modify its values at any time. The only required fields are Name, Label and Singular label.

4. Bridge

The add-on’s bridge is an extension of the generic REST bridge with some predefined defaults. Like the REST bridge, the addon’s bridge requires a post type, a backend, and an endpoint.

The endpoint of a Google Calendar bridge should be like /calendars/v3/calendar/${calendar_id}/events. The calendar ID can be found in your calendar settings page and it corresponds to the email address of your Google account.

Troubleshooting

To troubleshooting your bridges you can use the plugin’s debug console from the General Settings page. Enable the debug mode and submit a sample form response to see what’s going on under the hood. Take a look to our tutorial about how to use the debug console.

Common issues

  1. Authentication failures
    • Verify OAuth credentials
    • Check scope permissions
    • Regenerate client secret
    • Validate calendar permissions
    • If using external audience, check that your project has been verified
  2. Missing data
    • Verify that your form has date and time fields
    • Check field mapping
    • Consider API quotas and potential costs