Skip to main content

Posts

Showing posts from January 15, 2023

How to Login with Google API & store user data in MongoDB using Nodejs , expressJS , MongoDB

// Create a File passport.js  Before creating passport.js  we must have client id , and client secret- . Get your clientID & Client Secret from Google Developer Account using link https://console.cloud.google.com/apis/credentials/consent?project=vernal-zone-374906   // Make Oauth constent - UserType - External  == set/add scope email & profile  Then in Credential setting create new credentials to get Client Id and Client Secret  //passport.js import passport from 'passport'; import GoogleStrategy from 'passport-google-oauth2' import {Strategy} from 'passport-google-oauth2' passport.serializeUser((user , done) => { done(null , user); }) passport.deserializeUser(function(user, done) { done(null, user); }); passport.use(new GoogleStrategy({ clientID:"43989350384-ckjvij697vt7g3kdpg9dqe16k60k248.apps.googleusercontent.com", clientSecret:"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e", // Your Credentials here. callbackURL:"http://...