Skip to content

Instantly share code, notes, and snippets.

@johnknott
Created March 3, 2016 10:01
Show Gist options
  • Save johnknott/861fc101e9876593f841 to your computer and use it in GitHub Desktop.
Save johnknott/861fc101e9876593f841 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'google/api_client'
client = Google::APIClient.new(
application_name: 'Ruby Google Calendar Example',
application_version: '1.0.0')
calendar = client.discovered_api('calendar', 'v3')
key = Google::APIClient::PKCS12.load_key('./keys/creds.p12', 'notasecret')
asserter = Google::APIClient::JWTAsserter.new(
'<replace-with-your-service-account>@developer.gserviceaccount.com',
'https://www.googleapis.com/auth/calendar',
key)
client.authorization = asserter.authorize
query = { api_method: calendar.events.list,
parameters:
{ 'calendarId' => 'youremail@gmail.com',
'singleEvents' => true,
'maxResults' => 2500 }
}
result = client.execute(query)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment