Skip to content

How to Save User Data After Google Login (Next.js + Express + MongoDB) #1134

Discussion options

You must be logged in to vote

Hey @constant-infinite! 👋 Your flow looks solid and is a common pattern for Google OAuth in full-stack apps. Here’s a quick breakdown and some tips:
✅ Yes, your flow is correct:
Frontend triggers Google login → gets id_token
Send id_token to backend (POST /auth/google)
Backend verifies token (using google-auth-library)
Extracts user info → checks MongoDB
Creates user if new, or returns existing user

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@hiroshi960617
Comment options

Answer selected by constant-infinite
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants