Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction

This is how to set up Google Calendar sharing from Ruby on Railsdocument 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 your account and visit the Google Developers Console
  2. Set up your project if you haven't already done so and enable the 'Google Calendar API'
  3. Select your project and go to "APIs & auth", make sure "Google Calender API" is enabled.
  4. Click on 'credentials'.
  5. Click on "Create new client ID". Specify that your application type is service account, and proceed with the setup of the service account.
  6. At the end of this you should have:
Info

 

 

  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