Week 5: Google’s API Revealed Something Deeper
I had initially planned to make this post about connecting the public website to AWS, but I decided to go in a different direction. As I was reading through my peer’s comments, I saw one suggestion to implement Google’s registration API. I loved the idea; it would allow Google to deal with privacy concerns! After researching the API, I decided to test it out:
Step 1: download the allauth package
Step 2: add the authentication backends and installed apps to my django project
Step 3: Create superuser
Step 4: Enable the API
Step 5: Set up the credentials…this led to a few fundamental issues.
Step 1: Downloading the allauth package. the allauth package is a set of applications that help with authentication, registration, and account management. To install the package, I ran the following pip command:
pip install django-allauth
Step 2: Adding the authentication backends. To add this to ScrapSaver’s backend, I simply pasted the following into my settings:
Step 3: Creating a superuser. A superuser is just like any other user, but it has special privileges, like viewing admin settings and databases. This is helpful to test, debug, and view specific details. To create a superuser, I ran the following command:
python manage.py create superuser
Step 4: Enabling the API. An API is an Application Programming Interface, which connects two ends of software. For example, if I wanted to create an app that tells the weather, I could connect to the weather channel/app’s API to get that information. Most companies (like Google) have public APIs that are usable:
Step 5: Creating credentials. This is where I started noticing some fundamental problems in the way I set up my project. In the Scrapsaver Google account, you can see the Google API activated and ready to use:
As I went to create an OAuth 2.0 client, I realized that creating a new system of registration wouldn’t align with the way I had set my database up. As you can see in the models, the only object existing is the ingredients–users are a part of the ingredients. I realized that I needed to completely reorganize my database, and create different objects for everything I would store in my database. Additionally, I would need to create ingredient IDs to relate to every donation.
In hindsight, I should have considered all these things while building the initial database. However, I still think it’s a good idea to take a step back and fix the fundamental database issue before I move on to any other topics.
This week’s post began as the connection to Google’s API, but soon became a realization of something I missed. In the next post, I’ll describe how I created and structured this new database.