14
votes

I'm trying to implement server facebook authentication using passport-facebook on an iOS Facebook SDK app, and I'm unclear how to setup the passport authentication on the backend.

Basically the iOS client authenticates with Facebook and gets the sessionToken and I want to pass that to the passport-facebook /auth/facebook/callback to verify the session token with FB, and lookup the user from our database through node.js.

Is that the correct way to use passport-facebook, or do I need call /auth/facebook (and what parameters do I need to pass it).

This issue mentions building an app using Facebook iOS SDK and then authenticating on the server, but doesn't mention exactly how to do that.

https://github.com/jaredhanson/passport-facebook/issues/7

I could also write my own custom passport strategy that simply passes the FB session token and I can verify with FB graph API on the server to get the FB user ID and authenticate it's a valid session, as mentioned here: Design for Facebook authentication in an iOS app that also accesses a secured web service

1

1 Answers

21
votes

Check out passport-facebook-token, which is designed to authenticate based on a previously issued token (ie, the one issued to your iOS app).

passport-facebook is designed to do the web-based, redirect flow, which is not typically done from a mobile application.