# 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, public_profile"]
      }
    }
  }
}

# Application client and secret

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

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 (opens new window) requesting the additional fields.

Pro tip: Facebook API requests can be tested via the Graph API explorer (opens new window).

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

    Pro tip: See all available Facebook user options here (opens new window).

    Anything unclear or missing? Get help (opens new window) or Edit this page (opens new window)

    Last Updated: 11/17/2020, 3:17:03 PM