Summary
Keywords
Full Transcript
This video demonstrates how to implement GitHub OAuth login in a Node.js + Express application from scratch. It covers the entire OAuth2 flow: registering your app with GitHub, generating a secure state token, creating the Express login and callback routes, and handling the GitHub API calls. Key implementation steps include: .Registering a GitHub OAuth App – obtain the Client ID and Client Secret from your GitHub Developer Settings .Installing and using the “arctic” OAuth library – to generate a random state token for CSRF protection and build the GitHub authorization URL . Creating an Express Login Route – redirecting the user to GitHub’s authorization page using the Client ID and state . Handling the Callback Route – exchanging the returned code for an access token, then using that token to fetch the user’s GitHub profile (ID, name, email) . User Logic in the Callback – checking if a user already exists in your MySQL(via Drizzle), linking GitHub to an existing account, or creating a new user as needed. The video also walks through a MySQL schema for storing GitHub auth details. 📺 Watch the complete Node.JS Playlist here :https://youtube.com/playlist?list=PLwGdqUZWnOp3KELplHtc-RnJ5xTUPqdgH&si=_ob8F88HYxCdspup 🔥 Access Source Code, PPT & Notes here for Free : https://www.thapatechnical.com/2024/11/introduction-to-nodejs.html ------------------------------------------------------------------------ 🚀 Boost Your Skills with these Pre-Requisite Videos: 🔗 Best HTML Course - https://youtu.be/5ccq_nLHneE 🔗 Best CSS Course - https://youtu.be/MSICFljRcb4 🔗 JavaScript Basics Course Part 1 - https://youtu.be/13gLB6hDHR8 🔗 JavaScript Advanced Course Part 2 - https://youtu.be/YwsOCN8woA8 ------------------------------------------------------------------------ 💸 Build Your Own E-commerce Website for Free! - https://www.thapatechnical.com/2024/03/build-complete-ecommerce-website-using.html ------------------------------------------------------------------------ ✌️ Join Us! 🚀 Become a Member: Unlock perks, free source code, and more Join Now : https://www.youtube.com/channel/UCwfaAHy4zQUb2APNOGXUCCA/join 📷 Connect on Instagram: https://www.instagram.com/thapatechnical 🗨️ Join Our Discord Server: Hang out with fellow programmers Discord Link: https://discord.gg/MdScmCsua6 ------------------------------------------------------------------------ ⌛TIMELINE⏳ 0:00 – Introduction to GitHub Login 0:40 – Demo of GitHub Login Flow 2:25 – Mention Free/Premium Source Code 2:46 – Steps to Implement GitHub Login 4:00 – Getting Client ID and Secret from GitHub 7:42 – Generating State with ‘arctic’ Package 10:00 – Creating GitHub Login Route 13:15 – Creating GitHub OAuth Instance 15:10 – Redirecting URL to GitHub 17:45 – GitHub OAuth Page and Callback Handling 19:50 – Creating GitHub Callback Route 20:40 – Understanding Callback Controller 24:05 – Checking If User Exists 25:12 – Fetching GitHub ID, Name, Email with Token 30:20 – If User Already Exists (GitHub Linked) 34:30 – GitHub OAuth Schema Explained 36:15 – If User Registered but Not Linked to GitHub 38:00 – If User Not Registered (No GitHub Login) 41:10 – Final GitHub Login Check
