I am trying to fetch facebook user information using node-oauth but its giving missing page error on the browser when i am trying to perform oauth
Code oauth2.getAuthorize call:
app.get("/facebook/auth", (req, res) => {
var redirect_uri = "https://localhost:3000/facebook/callback"
var params = {
redirect_uri: redirect_uri,
scope: "user_about_me,publish_actions",
};
res.redirect(oauth2.getAuthorizeUrl(params));
});
Call to read code and access_token in oauth-redirected page
app.get("/facebook/callback", function (req, res) {
if (req.error_reason) {
res.send(req.error_reason);
}
if (req.query.code) {
var loginCode = req.query.code;
var redirect_uri = "https://localhost:3000/facebook/callback";
oauth2.getOAuthAccessToken(
loginCode,
{ grant_type: "authorization_code", redirect_uri: redirect_uri },
function (err, accessToken, refreshToken, params) {
if (err) {
console.error(err);
res.send(err);
}
var access_token = accessToken;
var expires = params.expires;
req.session.access_token = access_token;
req.session.expires = expires;
}
);
}
});