I watched a video and learnt about the passport package to handle the authentication and save the user data in MongoDB from Google. Passport is the middleware for NodeJS. It can be used to authenticate using a username and password, Facebook, Twitter, Google and more. It is simple to use and flexible. Steps to use passport package for google authentication: - install passport npm i passport passport-google-oauth20 --save I used the below code to handle the authentication. 1. This file has Google strategy to fetch the user's profile from user's Google profile and saving it in my MongoDB. passport.js const GoogleStrategy = require ( 'passport-google-oauth20' ); const User = require ( '../models/User' ); module . exports = function ( passport ) { passport . use ( new GoogleStrategy ({ clientID : process . env . GOOGLE_CLIENT_ID , clientSecret : process . env . GOOGLE_CLIENT_SECRET , callbackURL : '/auth/google/callbac...