-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basic api call to read calendar events in current month
- Loading branch information
1 parent
bfae43f
commit d4c6e6d
Showing
6 changed files
with
486 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,93 @@ | ||
# daily-event-publisher | ||
|
||
## Connect To Google Calendar Using A Service Account | ||
|
||
Before continuing, make sure you have a Google Account. | ||
|
||
### Project Creation | ||
|
||
* Go to the [Google Cloud Console](https://console.cloud.google.com/). | ||
* Click on the project drop-down and then click on NEW `PROJECT`. | ||
* Give your project a name and click `CREATE`. | ||
|
||
### Enable Google Calendar API | ||
|
||
* In the left sidebar, navigate to `APIs & Services` > `Library`. | ||
* Search for `Google Calendar API` and select it. | ||
* Click `ENABLE`. | ||
|
||
### Service Account Creation | ||
|
||
* In the left sidebar, navigate to `IAM & Admin` > `Service accounts`. | ||
* Click on `CREATE SERVICE ACCOUNT`. | ||
* Provide a name and description for the service account. Click `CREATE`. | ||
* Grant the service account the required permissions. For basic calendar access, you can choose `Role` > `Google Calendar API` > `Calendar Viewer`. Click `CONTINUE`. | ||
* Click `DONE`. | ||
|
||
### Download Credentials | ||
|
||
* In the service accounts list, find the service account you just created. | ||
* Click on its name to view details. | ||
* In the `KEYS` tab, click on `ADD KEY` > `JSON`. | ||
* A `credentials.json` file will be downloaded. This file contains the credentials your application will use to authenticate its API requests. | ||
|
||
### Share Your Google Calendar | ||
|
||
If you're intending to access a specific Google Calendar, make sure to share it with your service account: | ||
|
||
* Open [Google Calendar](https://calendar.google.com/). | ||
* Next to your calendar's name, click on the three dots and choose `Settings and sharing`. | ||
* Scroll to the `Share with specific people`` section. | ||
* Click on `+ Add people` and enter the email address of the service account (found in the service account details in Google Cloud Console). | ||
* Set the desired permissions (e.g., `See all event details`) and click `Send`. | ||
|
||
## Local Development | ||
|
||
### Prerequisites | ||
|
||
* **This project requires [Python 3.11](https://www.python.org/downloads/release/python-3113/).** | ||
|
||
* Dependencies are managed using [Poetry](https://python-poetry.org/docs/#installation). If you haven't installed it yet, use this command: | ||
|
||
```shell | ||
pip install poetry | ||
``` | ||
|
||
* [Pre-commit](https://pre-commit.com/) is used to enforce code quality. If you don't have pre-commit installed, you can install it using the following command: | ||
```shell | ||
pip install pre-commit | ||
``` | ||
### Setting up the Development environment | ||
1. Initialize pre-commit: | ||
```shell | ||
pre-commit install | ||
``` | ||
2. Install dependencies and activate the virtual environment: | ||
```shell | ||
poetry install | ||
poetry shell | ||
``` | ||
3. The following Environment Variables must exist locally to run this project. | ||
* `GOOGLE_CALENDAR_ID` - The ID of the calendar that is to be read from. | ||
* Go to [Google Calendar](https://calendar.google.com/). | ||
* Choose a Calendar: | ||
* On the left side of the page, you'll see a section titled `My calendars.` These are the calendars associated with your account. | ||
* Hover over the name of the calendar you're interested in. When you do, you'll notice three vertically aligned dots appear to the right of the calendar's name. This is the `Options` menu for that calendar. | ||
* Access Calendar Settings: | ||
* Click on the `Options` (three dots) next to the calendar name. | ||
* From the dropdown menu that appears, select `Settings and sharing`. | ||
* Find the Calendar ID: | ||
* In the settings page, scroll down to the “Integrate calendar” section. | ||
* Here, you'll find a field labeled `Calendar ID`. This is the ID you're looking for. It often looks like an email address and might end with @group.calendar.google.com. | ||
## Refrences | ||
* [Google Calendar API Python documention](https://developers.google.com/calendar/api/quickstart/python). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
__pycache__/ | ||
.vscode/ | ||
.pytest_cache/ | ||
credentials.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.