Hello, I have been stuck on this problem for the entire day. I am trying to implement facebook login in my MERN-STACK website with passport. Facebook login itself is not difficult, but afterward I don’t know how the client will get user info such as email, username and profile picts in the client.
Here is the code
passport.use(
new Strategy(
{
clientID: config.FACEBOOK_CLIENT_ID,
clientSecret: config.FACEBOOK_CLIENT_SECRET,
callbackURL: “/facebook/callback”,
profileFields: [“id”, “emails”, “displayName”, “photos”],
},
function (accessToken, refreshToken, profile, cb) {
// save the profile on the Database
// Save the accessToken and refreshToken if you need to call facebook apis later on
return cb(null, profile);
}
)
);
app.get(
“/facebook/callback”,
passport.authenticate(“facebook”, {}),
(req, res) => {
//*************************************
//Here we have req.user, that’s what I want to send back to the client.
//**********************************************
})
.redirect(“http://localhost:3000”);
}
);
The information I want is inside req.user, I have no clue how to send it back to the browser and can’t find a single tutorial on how that is done. What am I missing here? Please help me out.
submitted by /u/Novel_Ball_6146
[link] [comments]