Facebook

Facebook login can be initialized like any other oAuth provider by adding the app id and secret to config/default.json:

{
  "authentication": {
    "oauth": {
      "facebook": {
        "key": "<App ID>",
        "secret": "<App Secret>"
      }
    }
  }
}

Requesting the email property requires adding additional scope to the oauth configuration:

{
  "authentication": {
    "oauth": {
      "facebook": {
        "key": "<App ID>",
        "secret": "<App Secret>",
        "scope": ["email"]
      }
    }
  }
}

Application client and secret

The client id (App ID) and secret can be found in the Settings of the Facebook app:

Facebook app settings

Getting profile data

The standard oAuth strategy only returns the default profile fields (id and name). To get other fields, like the email or profile picture, the getProfile method of the oAuth strategy needs to be customized to call the Graph API profile endpoint https://graph.facebook.com/me with an HTTP request library like Axios requesting the additional fields.

Pro tip: Facebook API requests can be tested via the Graph API explorer.

The following example allows to log in with Facebook in the chat application from the guide: