Working with Node, Express, and Passport.
Okay, so my team and I are building a REST API for a dual-sided marketplace type application. We have already set up a basic Lo
The client side Facebook redirects are inconvenient when using native iOS and Android Facebook SDKs - as they sometimes redirect to the user installed Facebook app instead. Hence if you would like a really generic API then you should go with passport-facebook-token.
Verify if the 2 flows shown are correct.
Yes, they are correct.
Q: I have a list of APIs. How can I protect them with passport-facebook strategy
You have serveral options:
Facebook tokenFacebook token along with the user informationFacebook token each time it calls an APIFacebook tokenMore information about how to validate Facebook token here.
JWT after retreiving the Facebook user informationJWT each time it calls an APIJWTThis way, the server does not have to send the request to Facebook to validate the Facebook token. More information here.
Q: If I'm using passport-facebook-token, how do I tell user to go and login on facebook
Your /api/auth/facebook only accepts Facebook token and returns corresponding HTTP code. Thus, asking the user to go and login in Facebook is the job of the client.
More information about how to create a Facebook login manually here.