Facebook OAuth SSO Setup
This document will help you configure Facebook as an OAuth provider making Drupal as an OAuth Client. Following these steps will allow you to configure OAuth / OpenID Single Sign-On (SSO) between Facebook and your Drupal site such that your users will be able to login to your Drupal site using their Facebook credentials.
We provide Drupal OAuth & OpenID Connect Login - OAuth2 Client SSO Login module which is compatible with Drupal 7, Drupal 8, Drupal 9, Drupal 10, and Drupal 11.
Prerequisite:
- Install and activate the OAuth & OpenID Connect Login - OAuth2 Client SSO Login module on your Drupal site. Follow these steps to install the module.
Steps to configure Drupal as OAuth Client:
-
After installing the module, go to the Configuration tab and click on the miniOrange OAuth Client. (/admin/config/people/mo-oauth-client/mo-client-config)

-
In the Manage section, under the Client Configuration tab, click on the + Add New button to configure the desired OAuth Client.

- Provide the following information in the Client Configuration -> Add tab:
- Choose Facebook from the Select Application dropdown.
- Enter the Custom App Name of your choice. For example, Facebook.
- Copy the Callback/Redirect URL and keep it handy.

Configure OAuth SSO Application in Facebook (Meta):
- Sign in or sign up for your Facebook Developer console.
-
Go to the My Apps.

-
To build a new OAuth application, click the Create App button in the All Apps section.

-
Select "What do you want your app to do?" on the Create an App section. Then click the Next button to continue.

-
In the following screen, choose 'What do you need your app to do?' from the Select an app type section and click the Next button. (After your app is built, the app type cannot be changed.)

-
In the Details section, enter the Application name in the Add an app name text field and the App contact email (the default is your Facebook account email), then click the Create app button.

-
When you click the Create app button, a dialogue window will appear. For your security, you must re-enter your password to continue.

-
In the Add product to your app screen, click on the Set up button from the Facebook Login card.

-
Navigate to Products from the left navigation panel, then Facebook Login and Settings.

-
Under the Client OAuth Settings, paste the previously copied Callback/Redirect URL into the Valid OAuth Redirect URIs text field.

- Click on Save changes button to proceed.
-
Navigate to Settings on the left and select Basic.

Integrating Drupal with Facebook:
- Go to Facebook's developer console.
-
Copy the App ID (this is your Client ID) from the Basic section and keep it ready.

-
In Drupal's Configure OAuth tab paste the copied App ID into Client ID text field.

-
Navigate to the Facebook interface and click the Show button on the left side Basic tab.

-
Then, copy the App secret (your Client Secret).

-
In Drupal's Configure OAuth tab paste the copied App secret into the Client Secret text field.

-
After that, check the Scope and Endpoints, and then click on the Save Configuration button.
-
The Send Client ID and Secret in radio button allows you to specify whether the Client ID and Secret should be included in the header or the body of the Token Endpoint Request. If you're unsure which option to select, you can stick with the default settings.

You can also refer to the Facebook Endpoints and scope from the table given below:
| Authorization Endpoint | https://www.facebook.com/dialog/oauth |
| Access Token Endpoint | https://graph.facebook.com/v2.8/oauth/access_token |
| Get User Info Endpoint | https://graph.facebook.com/me/?fields=id,name,email,age_range,first_name,gender,last_name,link |
| Scope |
Test Configuration of Drupal with Facebook:
-
After successfully saving the configurations, click on the Perform Test Configuration button to check the OAuth SSO connection between Drupal and Facebook (Meta).

- On a Test Configuration popup, if you don't have any active session in Facebook on the same browser, you will be asked to login to your Facebook account. Once you are successfully logged into the Facebook account, you will be provided with a list of the attributes that are received from Facebook.
-
Scroll to the bottom and click on the Configure Mappings button.

-
Once you click on the Configure Mapping button, you will be redirected to the Attribute Mapping tab. From there, select the appropriate attribute from the OAuth Server Attribute dropdown where the email value is received, and then click the Save Configuration button.

Please Note: Mapping the Email Attribute is mandatory for your login to work.
Congratulations! You have successfully configured Facebook as an OAuth Provider and Drupal as an OAuth Client.
How to perform the SSO login?
- Now, open a new browser/private window and go to your Drupal site login page.
- Click on the Login using Facebook link to initiate the SSO from Drupal.
-
If the configuration is correct, you will be logged in to the Drupal site.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion