A Light weight system that helps to sync approved leaves from the Zoho People to Google Calendar.
Table of Contents
The project is about syncing all the approved leave will the leave type to google calendar of the organization. In order for the leave to appear in the Google Calendar the leave must be approved by all the stakeholder. This project uses Google Calendar API and webhook of Zoho People for approval in order to function properly.
Here's why the project is created:
- Previously, when a leave was approved, it require manual entry for the leaves in the calendar
- Time delay in entry of the leave resulted in a situation where critical meetings scheduled had to be shifted with clients
To get a local copy up and running follow these simple example steps.
For the project to run you will need to have the following:
- Requires
credentials.json
file. Follow here for details - Requires webhook that triggers when a leave is approved.
To locally run the project, follow the step below
-
Clone the repo
git clone git@github.com:proshore/zoho-google-calandar-event-sync.git
-
Copy the
.env.example
and create a new.env
file and add the information that is required. -
Run the docker compose command, this will install all the necessary dependency and runs the docker container.
docker-compose up
-
Follow the url on the output terminal to access the application, Default url should be http://127.0.0.1:5000
Before using Google APIs, you need to turn them on in a Google Cloud project. You can turn on one or more APIs in a single Google Cloud project. In the Google Cloud console, enable the Google Calendar API.
If you're using a new Google Cloud project to complete this quickstart, configure the OAuth consent screen and add yourself as a test user. If you've already completed this step for your Cloud project, skip to the next section.
-
In the Google Cloud console, go to Menu menu > APIs & Services > OAuth consent screen. Go to OAuth consent screen
-
For User type select Internal, then click Create.
-
Complete the app registration form, then click Save and Continue.
-
For now, you can skip adding scopes and click Save and Continue. In the future, when you create an app for use outside of your Google Workspace organization, you must change the User type to External, and then, add the authorization scopes that your app requires.
-
Review your app registration summary. To make changes, click Edit. If the app registration looks OK, click Back to Dashboard.
To authenticate end users and access user data in your app, you need to create one or more OAuth 2.0 Client IDs. A client ID is used to identify a single app to Google's OAuth servers. If your app runs on multiple platforms, you must create a separate client ID for each platform.
- In the Google Cloud console, go to Menu > APIs & Services > Credentials. Go to Credentials
- Click Create Credentials > OAuth client ID.
- Click Application type > Desktop app.
- In the Name field, type a name for the credential. This name is only shown in the Google Cloud console.
- Click Create. The OAuth client created screen appears, showing your new Client ID and Client secret.
- Click OK. The newly created credential appears under OAuth 2.0 Client IDs.
- Save the downloaded JSON file as
credentials.json
, and move the file to your working directory.
The project also contains a postman collection in the root, that helps to understand the API properly.
To generate the authentication token, Please visit the following link
{{baseurl}}/generate-token
An example can be for local development can be
http://localhost:5000/generate-token
This token will be used to create the calendar event and the owner of the event will be the account that has generated the link.
Note: In order for the event to be created the account needs to have the proper access for creation of events.
Prerequisite: Token must be present on the root of the project
A post request with the following parameter must be sent to the url provided below
Post | {{baseurl}}/zoho-calendar-sync
Parameters | Type | Required | Note |
---|---|---|---|
firstName | String | Yes | |
lastName | String | Yes | |
leavesFrom | String | Yes | Format: d-M-Y |
leaveTo | String | Yes | Format: d-M-Y |
leaveType | String | Yes | |
source | String | No | If not sent will take the default id from the service.py page |
Go to the PythonAnywhere Select Web on the main menu Select Flask app for the deployment Upload the files to the server created
Notice On PythonAnywhere, environment variables need to be explicitly set in your web app's configuration. You cannot use a .env file directly as you might do locally unless you explicitly load it within your application using a library like python-dotenv.
Thanks go to these wonderful people
Viraj Kumar Shrestha |