Redirect Messenger bot user to Messenger after Login with Passport

356 Views Asked by At

I have a simple passport router like this

app.get('/auth/facebook', 
    passport.authenticate('facebook',{ scope: ['user_likes', 'user_location'],
    session: true
    })
    );

app.get('/auth/facebook/callback', 
  passport.authenticate('facebook'), (req, res) => {
    var messengerApp = 'https://m.me/appUserName';
    res.redirect(messengerApp || '/');
});

app.get('/', function( req, res ){
  res.header( 'Content-Type', 'text/html' );
  res.status(200).send('<html><body><a href="/auth/facebook">Login with Facebook</a></body></html>');
});

This code will redirect the user to Messenger but skip the Login part. If I erase messengerApp ||, the code will redirect to the login button, but once the button is clicked the user is rediected to the same login button page '/'. How can I redirect the user to the conversation he has with my Bot on Messenger?

0

There are 0 best solutions below