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

Compare with Current View Page History

« Previous Version 4 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

 

 

 

  1. Install gem 'google-api-client'
  2. Sign in to your google account and visit: https://console.developers.google.com
  3. Click on APIs & auth/Credentials - Create new client ID (under OAuth)
  4. Select service account
  5. Copy private key to your local folder (in my case /Users/gijtenbeek/.eventr/<key>
  6. Sign in to the account of which you want to share the the google calendar
  7. Click on settings/calendars and 'edit settings' of the calendar you want to share
  8. In the field 'Share with specific people' add the developer email address: xxxxxx@developer.gserviceaccount.com
  9. select proper permissions
  10. Click on SAVE
  11. In your ruby code, the parameters you pass should contain calendarId. This is settings/calendars/calendar details
  12. See EventR for a working code sample
  • No labels