Login using Facebook
What You'll Need
Backbench account - Sign Up, the personal account will always remain free to use.
Facebook Developer account - Create an App on Facebook Developer account.
Demo
Prerequisites for the app
Setting up Facebook Login: Inside Facebook App click on Setup button below Facebook Login dialog. Now choose Web, for next prompt you'll be needing a Site URL. For that you can copy paste the URL mentioned in endpoint section of backbench.
Customizing Login Settings: Click on settings on Facebook app page, now it is required to put a valid redirect Oauth for the login. (This is the URI, where you'll be redirecting after successful sign in to Facebook) For the time being, you can put the endpoint that you copied above with
/fb
. Then you can paste it in the field given on Facebook. The Oauth redirect URI will look likehttps://USERID-BENCHID.backbench.io/fb
Making Facebook App Live: To switch from development to production mode, there is a toggle switch on the top of the app, you can switch it to
on
, to allow login from multiple accounts.Make a note of variables: Have of a note of following variables from your apps Basic Settings.
APP-ID, APP-SECRET AND REDIRECT-URI.
Frontend
Select +, in the upper right corner of File manager to create a html file . For example, say
fb.html
and select CREATE or hit Enter.Copy and paste the code module from below.
Replace APP_ID, REDIRECT_URI then hit save. (step-4 in prerequisites)
Backend
Select +, in the upper right corner to create a Module. For example, say "fb.js" and select CREATE or hit Enter.
Copy and paste the code module from below.
Replace APP_ID, APP_SECRET, REDIRECT_URI then hit save.
Now map this saved module, to an endpoint name
/fb.
(in endpoint section)
For Node.js App:
Select +, in the upper right corner to create a Module. For example, say "package.json" and select CREATE or hit Enter.
Copy and paste the code module from below.
A package.json file lists the packages that your project depends on. allows you to specify the versions of a package that your project can use using semantic versioning rules.
User Scopes
scope should be a comma or space separated list of Permissions to request from the person using your app.
For example to access to a subset of items that are part of a person's public profile. A person's public profile refers to the following properties on the user object by default:
id
cover
name
first_name
last_name
age_range
link
gender
locale
picture
timezone
updated_time
verified
Checking Login Status
A Manually Built Login must create their own way of storing when a person has logged in, and when that indicator is not there, proceed on the assumption that they are logged out. If someone is logged out, then your app should redirect them to the Login dialog at an appropriate time — for example if they click a login button.
Logout from Facebook
You can log people out of your app by removing/deleting the stored access token
from your app.
For a comprehensive guide see, Official Doc.
Last updated