Set up Google Single Sign-On (SSO) in the CoreX backend#39
Conversation
Alexandrbig1
left a comment
There was a problem hiding this comment.
@dikamjit-borah, please delete package.json file from your PR. I installed all packages that you need.
|
@Alexandrbig1 Please review and suggest changes if required. You will need to setup the following env variables locally.clientID: GOOGLE_CLIENT_ID, |
Alexandrbig1
left a comment
There was a problem hiding this comment.
Welcome to Open Code Chicago! 🎉
Thank you for making your first contribution here — we’re glad to have you. Approved. Great work!
|
@dikamjit-borah, congratulations on your merged PR! 🎉 Don’t forget to add yourself as a contributor using our |
|
@all-contributors please add @dikamjit-borah for code |
|
I've put up a pull request to add @dikamjit-borah! 🎉 |
|
Hey @dikamjit-borah , 🎉 Congratulations — your pull request has been merged! You’ve officially earned the Once claimed, you can proudly display it on your GitHub profile, Holopin board, or share it on LinkedIn to celebrate your achievement! Keep contributing, learning, and building with us 🚀 |
|
Hey @dikamjit-borah , 🎉 Congratulations on your first merged pull request! To celebrate this milestone, you’ve earned the “First PR Merged” badge on Holopin 🏅 Once claimed, you can proudly showcase it on your GitHub profile, Holopin board, or share it on LinkedIn to mark your first contribution to the open-source world 🌟 Keep contributing, keep growing, and welcome to the Open Code Chicago community! 🚀 |
|
Hey @dikamjit-borah , 🔥 Congratulations — your backend contributions have been outstanding! You’ve officially earned the Thank you for writing clean, secure, and efficient code that powers our project behind the scenes. — The Open Code Chicago Team |
Description
Set up Google Single Sign-On (SSO) in the CoreX backend to allow users to register/login with their Google account.
Implements Google OAuth 2.0 using Passport.
Adds endpoints:
GET /auth/google – redirects to Google for login
GET /auth/google/callback – handles Google’s response
Flow:
Verifies Google profile (id, email, name)
If user exists → returns JWT
If new user → creates user in MongoDB with authProvider: 'google', then returns JWT
Secure env vars:
GOOGLE_CLIENT_ID
GOOGLE_CLIENT_SECRET
GOOGLE_CALLBACK_URL
Documents setup and usage in README.md, including API details for frontend.
Closes: #
Type of Change
[x] New feature
[x] Documentation update
[ ] Bug fix
[ ] Refactor
[ ] Other (please describe):
Acceptance Criteria
[x] User can authenticate with Google and receive a JWT
[x] New Google users are automatically saved in DB
[x] Errors (invalid token, failure to fetch user) are handled
[x] API is documented for frontend use
Checklist
[ ] My code follows the style guidelines of this project
[ ] I have performed a self-review of my code
[ ] I have commented my code where necessary
[x] I have updated documentation (README, Usage, etc.)
[ ] My changes generate no new warnings or errors
[ ] I have added tests (if applicable)
[ ] All tests pass locally with my changes
How to Test
Set env vars: GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET, GOOGLE_CALLBACK_URL.
Start the server and ensure MongoDB is running.
Hit GET /auth/google, complete Google login, verify redirect.
Confirm
Existing Google user receives a valid JWT.
New Google user is created in MongoDB with authProvider: 'google' and receives a JWT.
Error paths return appropriate status and messages for invalid tokens or profile fetch failures.