简体   繁体   中英

Facebook login for mobile clients with Node express backend

I'm using parse-server (on heroku) as the backend for a mobile app.

Facebook login/signup will be an option for users.

What's the best workflow?

  1. I was thinking the mobile client could login to FB and pass the token to the express app. The express app could grab the data we need from FB and create/login the Parse user.

Is there a module where I can plug in the auth token and ping FB for the profile picture, DOB, or whatever else I need?

  1. Parse JS SDK has a facebookUtils API. Can I create a route that the mobile apps can hit in a browser to login to FB? If so how can I get the data I need from FB once they've logged in?

Any insight and sample code would be MUCH appreciated.

Thanks!

I have been using the facebook APIs for social login in my App, i used the first approach you mention ie

I was thinking the mobile client could login to FB and pass the token to the express app. The express app could grab the data we need from FB and create/login the Parse user.

I use two FB APIs, one for authenticating the app and the other for authenticating the user.

The mobile client fetch the acces token form facebook and passes to the backend express APP. the two APIs used are:-

  1. For authenticating the App

    https://graph.facebook.com/app/?access_token=

  2. For authenticating the user

    https://graph.facebook.com/me?fields=id,email,name,gender,picture&access_token="

ps you can select the parameter like name or email according to your need.

For authenticating the app, when you hit the API, you will get a json containing the FB_APP_id, which is unique and can be compared with the one provided by fb while you create your project on fb.

So far this approach is ok as my app is live and working fine.

There is another alternative in terms of what Node.js SDK you can use for Facebook integration. As a disclaimer, I do work for the company that provided this SDK: CloudRail .

Facebook is underneath two of the interfaces in that. Firstly, there is a Profile interface, that allows for management of social media sign in. As well as Facebook, it also includes Twitter, Slack and others.

Secondly, there is a Social Interface. This allows access to friend's lists and posts. Here there is only Facebook and Twitter. But, CloudRail is updated every week and new services are always be added.

Give it a check out to see if it fits your needs. One of the cool things about CloudRail is that all the methods work exactly the same for each interface; for example, once you get the hang of login with Facebook, it's exactly the same procedure for any of the other nine integrations we have in the Profile bundle.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM