passport / discuss

A forum for discussing topics related to the usage of Passport.js.
1 stars 0 forks source link

The req.user objected is empty. Hitting Route Using Postman #46

Closed Usama-Aslam closed 4 years ago

Usama-Aslam commented 4 years ago

Github Link : https://github.com/StackBeans/Review-App I can't access req.user when i send get/post or any call from Postman in localhost env. I want to build REST API using Postman. Its working fine in browser.

router.get("/facebook", passport.authenticate("facebook"));
router.get(
  "/facebook/callback",
  passport.authenticate("facebook", {
    successRedirect: "/api/auth/current",
    failureRedirect: "/api/auth/facebook",
  })
);

The /current route is just sending res.send(req.user)

router.get("/current", userCtrl.getUserInfo);

 //getUserInfo(req, res) {
 //   if (req.user) res.send(req.user);
//    else res.send({ error: "req.user not found" });
//  }

What should i do to get req.user when making call API using Postman. Please help me out. I am stuck.