Currently I am working on making an e-commerce site using nodejs and mongodb. I want to integrate Google's API on the signup and login pages. Do the experts have any idea about this?
Currently I am working on making an e-commerce site using nodejs and mongodb. I want to integrate Google's API on the signup and login pages. Do the experts have any idea about this?
Use the GoogleStrategy of passport.js library. example:
const passport = require('passport');
const { OAuthStrategy: { GoogleStrategy } } = require('passport-google-oauth');
passport.use(new GoogleStrategy({
consumerKey: GOOGLE_CONSUMER_KEY,
consumerSecret: GOOGLE_CONSUMER_SECRET,
callbackURL: "http://www.example.com/auth/google/callback"
},
(token, tokenSecret, profile, done) => {
User.findOrCreate({ googleId: profile.id }, function (err, user) {
return done(err, user);
});
}
));
read docs for more details http://www.passportjs.org/docs/google/
Try the following link, though It's already been mentioned in the comments below your question.
https://cloud.google.com/nodejs/getting-started/authenticate-users
It's the official google cloud platform documentation on how to get started authenticating users on node js. I hope it helps.
Creating a Google login will require you to work around with Google Developer Console.
I hope this link https://infantcoder.blogspot.com/2020/06/google-login-for-nodejs.html will help you create google login for your page.