Hello everyone,
In this blog post, I’ll discuss my second pull request (PR) as part of the Release 0.3 series for my assignment. This PR continues my work on the GitExplorer project, which I initially contributed to during the Hacktoberfest event. For this week issue, the project maintainer requested the implementation of GitHub authentication functionality.
GitExplorer is a project aimed at simplifying interactions with GitHub repositories. If you’re interested in learning more about the project or my previous contributions to it, feel free to check out my previous blog post for this repository.
The specific issue I tackled this time was the lack of GitHub authentication in the application. This limitation prevented the app from providing personalized features like starring repositories. My task was to implement a GitHub authentication feature that enables users to log in and log out using their GitHub accounts. Additionally, users would be able to star their favorite repositories and fetch a list of all their starred repositories with a simple button click.
GitExplorer does not use any modern UI frameworks like React. Instead, it relies solely on vanilla JavaScript, CSS, and HTML. While this simplicity has its advantages, it required me to dedicate more time to the issue as the original codebase was front-end focused. Adding GitHub authentication and related backend functionality meant venturing beyond the existing structure and implementing a server-side solution.
To support the new features, I first restructured the project. I moved all existing front-end code into a public folder and created a backend folder to house the server-side implementation. For the backend, I chose the Express framework as it integrates well with Passport.js, a library I used to handle GitHub authentication.
The steps included:
After setting up the backend, I integrated GitHub’s API to support the required functionality. This included:
Beyond implementing functionality, I focused on improving code quality by applying the DRY (Don’t Repeat Yourself) principle. I modularized the code by separating functions into reusable components, making it easier to maintain and extend in the future.
This was my first experience working with GitHub authentication, and it provided valuable insights into integrating third-party APIs and managing backend services. While the project initially appeared simple, working on both the front-end and back-end gave me a deeper understanding of full-stack development.
GitExplorer still has many interesting issues open for collaboration. If time permits, I plan to contribute further. The project has proven to be beginner-friendly while offering ample opportunities to learn new technologies and concepts.
Thank you for reading, and I hope this post inspires you to explore similar opportunities for learning and growth.
The above is the detailed content of Working with GitHub OAuth Authentication. For more information, please follow other related articles on the PHP Chinese website!