This week I have been looking into setting up the user registration system. Although I was blocked by the Facebook OAuth for two days, after looking into Google and Facebook’s API documentations and python-social-auth’s codebase, I was able to get the sign-in components working. By default, I don’t have access to a user’s email from the Facebook OAuth API (which I need to finish the user registration steps), and I don’t have access to the user’s profile picture from both services (which is something nice to have for the interface), so I looked into ways I could retrieve this information. After digging through many documentations and StackOverflow examples, I was able to figure out how to fetch it from Google and Facebook’s API endpoints. Specifically, I found the correct endpoints from both services so that I could send GET requests with an access token provided from OAuth to get the information I need. As shown below, while the resulting code only consists of a couple lines, it took a lot of documentation reading and trails and errors to find the correct parameters and API endpoints to make it work. Since the ways I can fetch the information are mostly the same for both services, the next step will be coming up with a suitable design pattern to achieve better reusability and scalability in case we need to add more OAuth providers in the future.
Next week I will finish up the user registration system and start working on the view methods for other pages. Since we have designed the class models for the database, the implementation should be trivial when compared to the OAuth component. Specifically, I will create the User model and a corresponding form to send to the user if they log in for the first time to complete their registration. I will also work with Jay to connect the backend logic with the user interface so that we can have a working prototype.