Dashing widget to display the next and some subsequent Google Calendar events using the Google Calendar API v3.
I use this widget to display my shift calendar - see the screenshot below
This widget works with API v3 and requires a service account to be set up via the Google Developer's Console. Once a project is set up, enable the Calendar API. On the Credentials page create a new OpenID and download the p12 key file - set up the path to this file in the job file and grant the email address access to the relevant calendar.
The job file defines how many events to get from the calendar and when to start the search. My version gets the next 6 events.
Add to Gemfile:
gem 'google-api-client', '>= 0.8'
Run
bundle install
Download the Moment javascript library and add to your javascript assets. Add #= require moment.js
to the application.coffee script. You can also use moment.min.js
if you've downloaded that.
Bit more info - I took a copy of the google_calendar.rb file and instead of trying to pass the data retrieved from the Google API i just printed it. I'm not a Ruby programmer at all, but hopefully this is right:
print events: result.data
This is giving me:
{:events=>#<Google::APIClient::Schema::Calendar::V3::Events:0x8ccc4c DATA:{"error"=>{"errors"=>[{"domain"=>"global", "reason"=>"notFound", "message"=>"Not Found"}], "code"=>404, "message"=>"Not Found"}}>}
Something's 404ing, which matches the errors I'm seeing on the Google API screen.
The P12 file and key file are related to the service account yes? Because it's not possible to download P12 files for OAuth 2.0 accounts, only the service accounts