Search code examples
node.jsexpressgoogle-oauthpassport.jsgoogle-people-api

GooglePlusAPIError: Legacy People API has not been used in project?


const router = require('express').Router();
const passport = require('passport');
// auth login
router.get('/login', (req, res) => {
    res.render('login', { user: req.user });
});

// auth logout
router.get('/logout', (req, res) => {
    // handle with passport
    res.send('logging out');
});

// auth with google+
router.get('/google',passport.authenticate('google',{
  scope:['email']
}));

router.get('/google/redirected',passport.authenticate('google',{
  successRedirect:"/",
  failureRedirect:"/login"
}),(req,res)=>{
  res.send('Redirected Successfully !')
})
module.exports = router;

GooglePlusAPIError: Legacy People API has not been used in project 297453248242 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/legacypeople.googleapis.com/overview?project=297453248242 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. at C:\Users\VAIBHAV\Desktop\GoogleAuth20\node_modules\passport-google-oauth20\lib\strategy.js:95:21 at passBackControl (C:\Users\VAIBHAV\Desktop\GoogleAuth20\node_modules\oauth\lib\oauth2.js:132:9) at IncomingMessage. (C:\Users\VAIBHAV\Desktop\GoogleAuth20\node_modules\oauth\lib\oauth2.js:157:7) at IncomingMessage.emit (node:events:525:35) at endReadableNT (node:internal/streams/readable:1359:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)


Solution

  • Go to google developer console for your project. Under library search for People api.

    Enable it.

    enter image description here