- Python 3.x (I'd used Python 3.10)
- Django 4.x (I'd used Django 4.1.5)
- Google developer console account
- A google calendar
-
Clone the repository
git clone https://github.com/AvanishCodes/convin.git -
Create a virtual environment and activate it
python3 -m venv myenv source myenv/bin/activate -
Install the dependencies
pip install -r requirements.txt -
Create a project in the Google developer console and enable the Google Calendar API. Also, register the url
http://127.0.0.1:8000/rest/v1/calendar/redirectas an authorized redirect URI. -
In the developer console, navigate to the
Credentialspage, create a new OAuth client ID, and specify authorized redirect URIs. -
Save the credentials from the same page in a file named
credentials.jsonin the root directory of the project. -
Start the development server
python3 manage.py runserver
You can test the integration by sending GET requests to the URLs that trigger the views and checking the responses.
-
Open a web browser and navigate to the URL for the GoogleCalendarInitView. For example, if the URL for this view is
/rest/v1/calendar/init/, you would navigate tohttp://localhost:8000/rest/v1/calendar/init/ -
The browser should redirect you to the Google authorization endpoint, where you will be prompted to enter your Google credentials and grant access to your calendar.
-
After granting access, the browser will redirect you to the URL for the GoogleCalendarRedirectView.
-
The view will handle the redirect request, get the access_token, and get the list of events in the user's calendar. The view will return the list of events in the response in json format.