You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Introduction

This document describes how to setup synchronization between a Rails application and Google Calendar. I am using the Google Calendar API v3 with OAuth2 and a service account to programmatically access and manage the calendar data.

Create the service account and its credentials

The service account will do the communication between the application and Google Calendar (through the v3 API). This account will at a later stage be used to impersonate the calendar user (in the same domain), so that all calendar updates appear to come from the calendar user, instead of the service account.

  1. Sign in to the account of which you want to share the Google Calendar.
  2. Visit the Google Developers Console
  3. Set up your project if you haven't already done so and enable the 'Google Calendar API'.
  4. Select your project and go to "APIs & auth", make sure "Google Calender API" is enabled.
  5. Click on 'credentials'.
  6. Click on "Create new client ID". Specify that your application type is service account, and proceed with the setup of the service account

You should now have

  • Client ID (xxx.apps.googleusercontent.com)
  • email address (xxx@developer.gserviceaccount.com)
  • A private key file

Share your calendar with the service account

 

Delegate domain-wide authority to your service account

 

 

  1. Install gem 'google-api-client'
  2. Copy private key to your local folder and set proper permissions
  3. In your ruby code, the parameters you pass should contain calendarId (primary) and person (the email address of the calendar user)
  4. See EventR for a working code sample
  • No labels