Search code examples
google-docsgoogle-docs-apigoogle-calendar-api

Populate a Google Doc or HTML doc with Google Calendar data


I need to generate a Google Document from a Google Calendar (using date ranges if possible). In the Google Doc I need to print:

date event title event description link to event attachment

and repeat for all events in the date range

Any suggestion? I don't know where to start.

Thanks in advance.


Solution

  • I needed to grab Google Calendar data and output it onto a web page.

    I started at https://console.developers.google.com/ where I created service accounts. On the backend (C#) I sent the service account email address and loaded a certificate (the X509... classes) to contact the API (https://developers.google.com/google-apps/calendar/overview). There are other ways of authenticating, because I was processing this on the backend, this was easiest for me.

    I then mapped the google model to my own local model, serialized it, and send it to the web page as JSON. Then I rendered my mustache-based template with the JSON data, and appended the output.

    I suppose in your case, rather than rendering the data you might build an HTML string in some form from the data and save that to a new file using the Google Drive API (https://developers.google.com/drive/v3/web/about-sdk) with probably a different service account.

    I hope this helped.