Facebook Strategy

Introduction

Passport Facebook authentication strategy using OAuth 2.0

Configuration sample object

Below is a configuration sample that is needed for the Facebook strategy to be configured. Follow the steps below the sample to get those configurations.


Configuration Sample
"facebook": {
    clientID: '%client_ID%',
    clientSecret: '%client_secret%',
    callbackURL: '%client_callback%',

	//optional
	scope: 'email',
	profileFields: ['id', 'email', 'name', 'displayName', 'gender']
}


Configuration Steps

1 - Create a Facebook application

You must register an app with Facebook in Developers Applications in Facebook's my apps menu.

Once an app is created, go to Settings → Basic to get clientID (App ID) and clientSecret (App Secret) that will be used in the strategy configuration in addition to a callback URL that you will define on the same page, scrolling down and adding a new platform (Website).

To set the callback URL, you have to add support to the platform you want to login. On Settings → Basic, scroll down and Add Platform.

Select Website.

Set the callback URL and save.

2 - Strategy Configuration

The passport-facebook strategy authenticates users using a Facebook user account and OAuth 2.0 tokens. Client ID and Secret granted in the creation of an app should be added to the config file as options so the strategy will be created. The callback URL will be used to receive the access-token, refresh-token, and profile which is the Facebook authenticated user profile.