Setup Facebook Single Sign-on with Drupal OAuth Client
Overview
Drupal Facebook SSO integration will allow you to configure Single Sign-On ( SSO ) login between your Drupal site and Facebook using OAuth/OpenID protocol. Drupal OAuth 2.0/OpenID connect module gives the ability to enable login using OAuth 2.0/OIDC Single Sign-On to Drupal Site. We provide the Drupal OAuth/OpenID Client module for Drupal 7, Drupal 8, Drupal 9 and Drupal 10 and Drupal 11.
Installation Steps
- Using Composer
- Using Drush
- Manual Installation
Configuration Steps
Setup Drupal as OAuth Client
- After installing the module, navigate to the Configuration -> miniOrange OAuth Client Configuration -> Configure OAuth tab and select Custom OAuth 2.0 Provider from the Select Application dropdown list.
- Copy the Callback/Redirect URL and keep it handy.
- Enter the application name in the Display Name text field. For example, Facebook.
Note: If your provider only supports HTTPS Callback/Redirect URLs and you have an HTTP site, please make sure to enable the 'Enforce HTTPS Callback URL' checkbox at the bottom of the tab.
Create Application in Facebook
- Sign in or sign up at the Facebook Developer console and go to the My Apps.
- Navigate to the All Apps section and click on the Create App button to build a new OAuth application.
- Select the option as your need to create an App and click on the Next button.
- Select an app type 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.
- After clicking the Create app button, a dialogue box will display. For your security, you must re-enter your password and click on Submit.
- In the Add product to your app section, click on the Set up button of the Facebook Login card.
- Navigate to the Products -> Facebook Login -> Settings from the left navigation panel.
- Go to the Client OAuth Settings and paste the Callback/Redirect URL into the Valid OAuth Redirect URIs text field.
- Click on Save changes button.
- Navigate to Settings -> Basic from the left navigation panel.
Integrating Drupal with Facebook
- Navigate to Facebook's developer console.
- Copy the App ID.
- Click on the Show button of the App secret and copy the App secret.
- Go to Drupal's Configure OAuth tab and paste the copied App ID and App Secret into the Client ID and Client Secret text fields respectively.
- Check the Scope and Endpoints, and then click on the Save Configuration button.
- You can also refer to the Facebook Endpoints and scope from the table below:
Scope | public_profile email |
Authorize 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 |
Test Configuration of Drupal with Facebook
- Click 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 log into the 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.
- Select the Email Attribute from the dropdown menu in which the user's email ID is obtained and click on the Done button.
- After clicking on the Done button, you will be redirected to the Attribute & Role Mapping tab. Here, you can also choose the Username Attribute from the dropdown and click on the Save Configuration button.
Note: Mapping the Email Attribute is mandatory for your login to work.
How to perform the SSO
- Open a new browser/private window and navigate to the Drupal site login page.
- Click on the Login using Facebook link to initiate the SSO from Drupal.
- If you want to add the SSO link on other pages, please follow the steps given in the image below:
Need Assistance?
If you face any issues during the configuration or if you want some additional features, please contact us at drupalsupport@xecurify.com.
Additional Features:
Troubleshooting:
More FAQs ➔Getting error: 'Username not received. Check your Attribute Mapping configuration.' OR Getting Error: 'Email not received. Check your Attribute Mapping configuration.'
Follow the steps mentioned HERE
I am getting "Client Credentials were not found in
the headers or body"
when I try to perform test configuration
Follow the steps mentioned HERE
After I click on the logout in Drupal, it sends me back to the Drupal homepage. However, when I try to login with other user, it doesn't ask me to login but automatically logs me in with same user
The logout functionality you've mentioned here is the default behavior of a module. It's logging you out of Drupal but not from your Application/Provider. To allow the module to logout from your provider/application account (what you are looking for), you need to make the below configurations: [know more]
I purchased the paid Drupal module and replaced it with the free module, but still I am not able to use paid features.
As you have upgraded to one of our paid versions of the Drupal module and replaced the free module with the paid one, you must first activate the paid module. Please refer to the below steps. [Know more]
[MO_CONTACT_US]