Tag Archives: Social Login

Back to blog home page

New Feature: Facebook Graph API Support

Posted by on Dec 06, 2016

We’re pleased to announce Backand support for the Facebook Graph API. The Graph API gives your application access to user’s Facebook profiles (with their permission, of course). With it, you can retrieve data such as birthdays, friends list and profile photos and enrich the data of your app running on the Backand, backend-as-a-service (BaaS).

Retrieving data from Facebook using the Graph API

To retrieve data from Facebook using the Graph API, get the Facebook user ID after the user signed up to your Backand app. Once you have the Facebook user ID, use the Facebook graph API to retrieve data or perform other actions.

To get the Facebook user ID (FUID) in Backand, follow these steps:

  1. Open Security & Auth >> Security actions menu and Edit “beforeSocialSignup” action
  2. Change the Where Condition to true (bottom of the page)
  3. Uncomment the code that saves the Facebook user id:userInput.fuid = parameters.socialProfile.additionalValues.id;
  4. Save the Action

Next you need to add the fuid field in the users object:

  1. Open the model page under objects menu
  2. Add new Field in the users object named fuid
  3. Click Validate & Update and Ok in the dialog

Now, when a user signs up to your app using Facebook as a social login provider, you will see the users’s FUID in the users object.

Getting Facebook data in Backand code

Once you have the Facebook user ID, use the Graph API to access any available Facebook data.

  1. The FB Graph API docs
  2. You also would need access token of your app, use this FB tool to get it.
  3. More FB tools
  4. For example, to get a user’s friends use the following JavaScript action code:

Getting a Facebook profile image

To get the Facebook profile image you just need to point to the following URL with a correct FUID:

http://graph.facebook.com/{fuid}/picture

or

http://graph.facebook .com/10209560720107355/picture?type=large

You can also review Facebook’s docs on how to use the Graph API.

​Don’t have a Backand backend-as-a-service account? Why not get one now?  Get Free Backand Account.