Open shibichakkaravarthy opened 1 year ago
I have follewed the steps mentioned in the documentation and still can't figure out what mistake I'm doing. Here is the code...
passport.use( "instagramFB", new FacebookStrategy( { clientID: FACEBOOK_APP_ID, clientSecret: FACEBOOK_APP_SECRET, callbackURL: "http://localhost:3000/instagram/accounts", profileFields: ["id", "displayName", "photos", "email"], scope: [ "user_posts", "pages_read_engagement", "pages_manage_posts", "publish_video", ], }, function (accessToken, _, profile, cb) { console.log("InstagramProfile", { profile, accessToken }); return cb(null, { ...profile, accessToken }); } ) ); passport.serializeUser(function (user, cb) { console.log("SERIALIZE", user); process.nextTick(function () { cb(null, { id: user.id, username: user.username, name: user.name }); }); }); passport.deserializeUser(function (user, cb) { console.log("DESERIALIZE", user); process.nextTick(function () { return cb(null, user); }); }); // This is the endpoint called when fb login is invoked export const instagramAuth = (req, res, next) => { passport.authenticate("instagramFB", { state: JSON.stringify({ userId: req.params.userId }), authType: "reauthenticate", })(req, res, next); }; // This is the callback Endpoint export const getConnectedAccounts = async (req, res) => { try { console.log("CALL BACK", req.user, req.query); res.status(200).json({ pages: "" }); } catch (error) { console.log("error", error); res.json({ error }); } };
I'm supposed to get the access token and profile in req.user according to docs but it is undefined and I'm getting a "code" in req.query. Somebody please help me out with this...
I have follewed the steps mentioned in the documentation and still can't figure out what mistake I'm doing. Here is the code...
I'm supposed to get the access token and profile in req.user according to docs but it is undefined and I'm getting a "code" in req.query. Somebody please help me out with this...