Skip to content

The aim of this project is to create a Google Calendar API Service that abstracts away the complexity of the google calendar API. Letting other APIs and Scripts create, retrieve, update and delete Events for a single a calendar.

Notifications You must be signed in to change notification settings

contre95/google-calendar-serverless-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Calendar API

The aim of this project is to create a Google Calendar API Service that abstracts away the complexity of the google calendar API. Letting other APIs and Scripts create, retrieve, update and delete Events for a single a calendar.

Getting Started

Create the Service Account

In order to be able to access Google Services, go to Google Developers Console and create a new project. On the left menu, select Credentials , then Create credentials. Select Service account key from the type of credentials list. After this, choose New service account, JSON as a private key type and hit Create button which will trigger the download of the JSON private key. Then cp those privatekeys.json into ./config/privatekeys.json. These keys would then be accessed by the serverles.yml to run the lambda function with information needed to authenticate as environment variables.

Enable the Calendar API

Then you will need to enable the APIs which will be used with this service account. To do that, select Library from the left menu and then search for “Google Calendar API” and press the Enable button

Grant the Service Account access to the API

The access is granted by assigning permissions to the service account, using its email address. In the case of the Google Calendar API you can share the complete calendar or single events from the Calendar App.

Prerequisites

To run this service you will need to have Node JS. and npm or any other package manager.

Installing

Clone the repo and cd to the folder. The run the following commands:

$ sudo npm install serverless -g
$ sudo npm install

Running development

$ sls offline start

This should prompt something like this:

Serverless: Starting Offline: dev/us-east-1.

Serverless: Routes for eventsHandler:
Serverless: GET /event
Serverless: GET /event/{id}
Serverless: POST /event
Serverless: PUT /event/{id}
Serverless: POST /{apiVersion}/functions/calendar-api-dev-eventsHandler/invocations

Serverless: Offline listening on http://localhost:3000

Deployment

You will need to have the awscli installed and previously generated a key pair. In order to configure your aws profile with $ aws configure. Once configured you can deploy everything with.

$ sls deploy 

You can optionally add the --verbose flag to debug any errors if any.

Usage

Pourpose

This API is intended to let other scripts easily create and modify events for a given calendar created beforehand and specified in the configurations files before the deployment. Nevertheless, the calendar can be easily changed by sending it as a parameter of the http request.

POST and specific event:
curl -X POST -H "Content-Type: application/json" -d @example-payload.json localhost:3000/event | jq
UPDATE an event:
curl -X PUT -H "Content-Type: application/json" -d @example-payload.json localhost:3000/event/customid123123 | jq
GET the upcoming events:
curl -X GET 'http://localhost:3000/event?max_result=10' | jq

Note: Please notice that a good way of keeping track of the events created is to POST an event with a custom id otherwise the id is automatically created by the Calendar API. For event IDs and further parameter constraints please refer to the Google Calendar API reference

Built With

Authors

License

This project is licensed under the MIT License

About

The aim of this project is to create a Google Calendar API Service that abstracts away the complexity of the google calendar API. Letting other APIs and Scripts create, retrieve, update and delete Events for a single a calendar.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published