Reputation: 53
I'm in the process of building a website and want to include a component that lists the three next upcoming calendar events from a public Google Calendar. I'm building the site using GatsbyJS, and so will be using Node.js to process the data and display it correctly on the page. What I'm not quite sure how to do, however, is interface with the Google Calendar API in the first place; I'm building a static site with no backend, so will need to interact with the API clientside instead.
I've done a bit of reading and found the documentation for Googles Node.js Client. It lists three different ways of interacting with the API but I'm not sure which is more appropriate for my situation? I think I've rules out OAuth2 since it sounds like individual users would need to sign in with their Google accounts in order for the calendar event pulling to work correctly (which is hardly a good solution). Which of the other two options do you think I should be using?
Also, are there any security concerns I should be taking into account, given it's likely the website might be storing API keys and/or client IDs in a publicly accessible way?
Upvotes: 0
Views: 201
Reputation: 2616
The API key method stores your API key and is no different than including it in plaintext in the query string when loading e.g.
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" async defer></script>
When you create the key, you can then restrict its usage to certain HTTP referers etc.
Upvotes: 1