Sync Google and SharePoint Calendars

The CData Data Providers make it easy to build applications that need to move data from one source to another. You can use standard SQL to retrieve and update data in Google and SharePoint. This article shows how to use the demo Windows application to sync Google and SharePoint calendars.

Connect to Google and SharePoint

To connect to Google, you will need to use the OAuth standard. You will need to register an app to obtain the OAuth client Id and client secret. You can then set InitiateOAuth to complete the OAuth process. When you connect, the provider will open the URL to the Google OAuth endpoint in your default browser. After logging into Google, you will be prompted to grant permissions to the application. See the "Getting Started" chapter in the help documentation for a guide to obtaining the OAuth authentication values.

To connect to SharePoint On-Premise, specify the User and Password properties and set the AuthScheme to NTLM. To connect to SharePoint Online, set AuthScheme to NONE and set the User and Password connection string properties. For more details on connecting to SharePoint Online, see Integration With SharePoint Online.

See the "Getting Started" chapter in the help documentation for a guide to connecting with the providers.

Retrieve the Events

Follow the steps below to use simple SQL queries to retrieve calendar events from Google and SharePoint.

  1. Google accounts can have several calendars. Obtain a list of a user's Google Calendars by issuing a query to the Calendars table. For example: SELECT * FROM Calendars.
  2. In order to get a list of the events from a given Google Calendar, issue a query to the CalendarEvents table that specifies the CalendarId in the WHERE clause. The resulting events can be further filtered by using the StartDateTime or EndDateTime columns. For example:
    SELECT * FROM CalendarEvents
        WHERE  (CalendarId = '') 
    	AND (StartDateTime >= '1/1/2012') 
    	AND (StartDateTime <= '2/1/2012')
  3. The SharePoint data provider models each SharePoint list as a table. Get the events in a particular calendar by querying the table with the same name as the list. The events may be filtered further by specifying the EventDate or EndDate columns. For example:
    SELECT * FROM Calendar
        WHERE (EventDate >= '1/1/2012') 
    	AND (EventDate <= '2/1/2012')

Synchronize the Events

Synchronizing the events is a simple process. Once the events from Google and SharePoint are available they can be compared and synchronized based on user preference. The sample application does this based on user input, but it is easy to create one that does the synchronization automatically. The standard SQL syntax of the CData data providers makes it easy to create, update, or delete events as needed.

Pre-Built Demo Application

You can run the demo application by downloading the executable for the demo application.

Source Code

You can download the full source of the demo application; you will also need the Google ADO.NET Data Provider and the SharePoint ADO.NET Data Provider.