Skip to content

Commit

Permalink
docs: update readme with service account configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilanga committed Nov 9, 2023
1 parent 8009874 commit 3dc2993
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
# Booking Pal Service

Booking pal service is a web service that allows booking pal IoT clients to connect and manage their room calendars.
Booking pal service is a REST web service that allows booking pal IoT clients to connect and manage their room calendars.

## Configurations

Project is in initial stages and is not added proper configuration approaches. However, You can add your authorised google credentials json manually and add the nessasary configuration as below.
This service is using service account key to connect to Google Calendar API. Each calendar should have its own service account key. The service account key should be placed in `calendarCredentials` database table. The service account key should be in JSON format and stored in the `serviceAccountKey` column. Calendar Details table should have correct mapping to the valid calendar credentials.

Follow Google's guide to obtain the OAuth JSON file and store it in `src/lib/gcal/config/client_secret.json` before starting the project.
To configure the service account for google calendar API, follow the steps below:

You will be asked to enter the calendar ID (the calendar ID can be found on the settings page of your calendar in Google Calendar)
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
2. Create a new project
3. Go to [Google Calendar API](https://console.cloud.google.com/apis/library/calendar-json.googleapis.com)
4. Enable the API
5. Go to [Google Cloud Console Credentials](https://console.cloud.google.com/apis/credentials)
6. Create a new service account
7. Download the service account key in JSON format
8. Store the service account key in `calendarCredentials` database table

Open the link printed in the terminal, login with the same user as before to obtain the OAuth JSON file and authorize the app to access Google's API. You now get a token from the browser URLs query parameter. Enter that token in the terminal's prompt.
> You may need to share your calendar with the service account email address.
Also, get the calendar ID from your calendar settings and store it in the `calendarDetails` database table.

Please refer to this documentation on how to configure the service account key: [https://developers.google.com/identity/protocols/oauth2/service-account](https://developers.google.com/identity/protocols/oauth2/service-account)

### Database

Database has two configuration tables:

1. `calendarCredentials` - This table stores the service account key for each calendar or set of calendars. The service account key should be in JSON format and stored in the `serviceAccountKey` column.
2. `calendarDetails` - This table stores the calendar details. The calendar ID should be stored in the `calendarId` column. The `calendarCredentialsId` column should be mapped to the correct `calendarCredentials` table row. The `calendarName` column should be the name of the calendar. `apiKey` column should be the API key for the calendar. API key is used to authenticate the IoT client to the valid calendar.

### Environment Variables

| Name | Description | Default Value |
|------|-------------|---------------|
| `PORT` | The port to run the server on | `3000` |
| `DATABASE_URL` | The database connection string | `postgres://postgres:postgres@localhost:5432/booking-pal` |

## Getting Started
## Project Structure

This is created using [Bun](https://bun.sh/) and [Elysia](https://elysia.to/). To get started, install bun globally:

Expand Down

0 comments on commit 3dc2993

Please sign in to comment.