Enable the Calendar API

In order to communicate with the Google Calendar API, the first thing you need to do is enable the Google Calendar API and download your OAuth credentials. Head over to https://developers.google.com/calendar/quickstart/python and click on the Enable the Google Calendar API button.

A dialog will come up asking you to enter a new project name. You can use the default name or change it if you want. We kept the name Quickstart, so you may see references to it in the following images. Click Next.

Next it will ask you to configure your OAuth client by choosing an App Type. You can leave it at the default value of Desktop app. Go ahead and click Create.

Finally, another dialog will come up telling you that you're all set. Click on the Download Client Configuration button.

This will download a file called credentials.json. Go ahead and save this file in a safe place. Once it is done downloading, you will want to upload it to your Pi into the main folder that you will be running your script. A good place is inside of /home/pi.

Install the Google API Package

There is one last set of packages that you will need to install in order to run this project:

pip3 install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib

Set your Timezone

If you haven't done so already, be sure your timezone is set correctly. A freshly setup Raspberry Pi is usually set to GMC by default. You can change it by typing:

sudo raspi-config

Then select Localisation Options and Change Time Zone. This will ensure that everything displays with the correct time and date. You can find more information about using raspi-config in the official documentation.

Upload the Project Files

In order to communicate with the Google Calendar API, you will need what is called an OAuth token. The first time you run the script, you will be given a URL that you can paste into your browser to finish the token setup procedure. Go ahead and upload the script to the same folder that you uploaded the credentials file. Run the script by typing the following:

python3 desk_calendar.py

Generating an OAuth Token

If you haven't previously run the script, you will be taken through a process that generates an OAuth token, which allows the application to communicate with the Google Calendar API securely.

The script should provide a URL to visit to generate the token. Go ahead and copy and paste the URL into a browser.

You may run into an alert that says your app isn't verified. Go ahead and click on the Advanced link.

That will expand the dialog. Click Go to Quickstart (unsafe) or whatever you decided on for a project name.

Next, you will be asked to grant permissions to view your calendar. Go ahead and click Allow.

After all that, it will come up with a confirmation dialog with your account name and the permissions that you are granting. Go ahead and click on Allow.

Finally, you will be given an Authorization Code. Click on the Copy icon and it will get copied to your clipboard.

Paste the Authorization Code back into the Python script and the token will be generated and saved for next time.

The script will automatically resume and your E-Ink display should be updated with the next event in your calendar.

You should now see something similar to this on your ePaper display.

Resetting your token

If for whatever reason you would like reset your token, you can do so by removing the file token.pickle from the same folder where you ran the script:

rm token.pickle

Just re-run the event calendar to go through the steps again.

This guide was first published on Jul 22, 2020. It was last updated on Jul 22, 2020.
This page (Google Setup) was last updated on Sep 18, 2020.