Add a Facebook IdP
On this page
Add a Login with Facebook button to the FusionAuth login page. This guide shows how to collect the credentials from Facebook and configure the Facebook Identity Provider, a Social loginLogin through an account the user already has with a consumer service, such as Google or Apple. option.
After you configure the Identity Provider, you can enable the Facebook login button for one or more FusionAuth Applications. The following login page shows the Facebook Identity Provider:

The following diagram shows a login through Facebook on the FusionAuth hosted login pages:
A user logs in through an Identity Provider on the FusionAuth hosted login pages.
The user sees only the FusionAuth login page, the login page of Facebook, and your application. Your application completes a standard OAuth authorization code grant with FusionAuth, and FusionAuth handles the exchange with Facebook.
Create a Facebook Account#
When you don't have a Facebook account, create one at Facebook.
Add a Facebook Application#
The Login with Facebook option needs a Facebook application. To create one, open your Facebook developer account.
Create a New App Id#
Click Create App . Facebook shows the Display Name of the application to users when they log in to FusionAuth with Facebook. Complete the form and click Create App .

Configure Facebook Login#
Add the Facebook Login product to the new application:
- Open the Add a Product page. Facebook usually shows the page after you create the application. Otherwise, find the Products + or Add Product section.
- On the Facebook Login tile, click Set Up . The Products section of the application now lists Facebook Login .
- In the left navigation, under Facebook Login , click Settings .
- Review the settings against your security requirements. The default Client OAuth Settings usually work.
- When you use the redirect login method, add the absolute URL of the FusionAuth callback endpoint, such as
https://login.piedpiper.com/oauth2/callback, to Valid OAuth Redirect URIs. - When you use the popup login method, fill in App Domains, User Data Deletion, and Privacy Policy URL. In App Domains, add the top-level domain of the login page. For example, a login page at
https://login.piedpiper.comneedspiedpiper.com.

Collect the App ID and App Secret#
The FusionAuth configuration needs the App ID and the App Secret. To find the values, navigate to Settings -> Basic in the left navigation. Record the values, or keep the page open to copy the values in the next step.
The application starts in development mode. To make the application public, switch App Mode to live. Facebook then asks you to complete other settings. You can log in with the application in development mode.

Create a Facebook Identity Provider#
Create the Facebook Identity Provider in FusionAuth. Fill in App Id and App secret with the values from the Facebook console. Button text is required and defaults to Login with Facebook.
To enable Facebook for an Application or CIMD domain:
-
In the Admin UI, navigate to Settings -> Identity Providers .
-
Click the arrow next to the add button, and select Facebook .
-
Select the Tenant for the Identity Provider, or select
Global identity provider. You can't change the scope later. For more information, see Identity Provider Scope. -
Fill out the form. Your identity provider supplies most of the values. For a description of each field, see Form Fields.
-
On the Applications tab, turn on Enabled for each Application or CIMD domain that uses the Identity Provider.
-
To register new users for the Application with the Application's default roles, turn on Create registration. When Create registration is off, a user needs a registration for the Application before the user can log in through the Identity Provider.
-
Click .
The login page of each enabled Application then shows a login button for the Identity Provider. An Identity Provider with managed domains asks for the user's email address instead of showing a button.

Form Fields#
IdAn optional UUID. When you leave out the Id, FusionAuth generates a unique Id.
TenantThe Tenant that this Identity Provider belongs to. The field appears only when you select a specific Tenant on the previous page. When you select Global identity provider on the previous page, the field doesn't appear.
NameA unique name for the Identity Provider. FusionAuth uses the name for display only, and you can change the name later.
App IdThe App ID from the settings of your Facebook application.
App secretThe App Secret from the settings of your Facebook application.
Button textThe text of the button on the login form. The default value is Login with Facebook.
FieldsThe fields that FusionAuth requests from the user during login. email is the minimum that login requires. When you leave the field blank during an edit, FusionAuth keeps the existing value.
To request more fields, such as the name and birthday, list the fields: email,name,first_name,last_name,birthday. For more information, see the Facebook Graph API documentation.
Login MethodWhat happens after the user clicks the Identity Provider button, such as Login with Facebook:
Use redirect for login: FusionAuth redirects the user to a Facebook login page. After the user authenticates, Facebook redirects the user back to FusionAuth. Set the redirect URLThe URL where the authorization server sends the browser after login, with an authorization code or an error. to an absolute URL in the Facebook console for your application. For a hostname oflogin.piedpiper.com, the redirect URL ishttps://login.piedpiper.com/oauth2/callback/.Use popup for login: FusionAuth opens a popup where the user logs in with Facebook. After the user authenticates, the popup closes. Fill in App Domain, User Data Deletion, and Privacy Policy URL in your Facebook application settings, and turn on Login with the JavaScript SDK.
When the OAuth Authorize endpointThe OAuth 2.0 endpoint where a user logs in and grants an application access. In FusionAuth, the authorization endpoint is /oauth2/authorize. request includes an idp_hint, FusionAuth uses the redirect method, even when you select Use popup for login.
PermissionsThe permissions that FusionAuth requests from the user during login. email is the minimum that login requires. When you leave the field blank during an edit, FusionAuth keeps the existing value. For more information, see the Facebook Login documentation.
Linking strategyHow FusionAuth links a Facebook user to a FusionAuth user. For more information, see Linking Strategies.
Available since 1.65.0 You can only change this value when the identity provider is disabled. To change the linking strategy for an identity provider that is already enabled, disable the provider, change the value, and then re-enable the provider.
Reconcile lambdaA lambda that maps custom claims from Facebook to the user.
To create a lambda, navigate to Customizations -> Lambdas .
Enable debug loggingCreates Event Log entries that help you debug integration errors. To read the entries, navigate to System -> Event Log .
Tenants#
The Tenants tab limits the number of links that each user in a Tenant can have to this Identity Provider. Links to other Identity Providers don't count toward the limit. On a global Identity Provider, the tab starts empty. To set a limit for a Tenant, click Add tenant configuration . On a tenant-scoped Identity Provider, the tab lists only the Identity Provider's Tenant.
Limit links per userWhen turned on, FusionAuth enforces Maximum link count for users in the Tenant.
Maximum link countThe maximum number of links that a user can have to this Identity Provider. When a user reaches the limit, FusionAuth rejects a new link. The Link API returns a 400, and the hosted login pages show an error.
For more information, see Identity Providers and Tenants.
Building Your Own Integration#
To build your own login experience instead of using the FusionAuth hosted login pages, start the Identity Provider flow in your application, and complete the login with the Login API. The following diagram shows the flow:
Your application starts the Identity Provider login and completes the login with the FusionAuth API.
For the request that completes the login, see the Facebook Identity Provider API.
When your application needs a refresh token after the login, turn on Enable JWT Refresh for the Application. In the Admin UI, navigate to Applications -> Your Application -> Security -> Login API settings .
Related
Learn about the APIs for creating, retrieving, updating and disabling a Facebook identity provider.
Learn how FusionAuth delegates login to external identity providers.
Learn how to map the data from a Facebook login to a FusionAuth user and registration with a reconcile lambda.
Learn about the APIs for creating, retrieving, updating and disabling an Apple identity provider.