Sorry, you need to enable JavaScript to visit this website.

Add Drupal 8 login with facebook button

Submitted by abhaisasidharan on Sun, 03/15/2020 - 05:57
Login with facebook
Login with facebook

A login with facebook, google or twitter (or any of the many social media out there) button is essential now because people are lazy. They don't want to fill up forms to sign up to a web service. One click login/sign up is the perfect solution.

Login with facebook is quite simple. All you have to do is install the module and create a facebook app. The social_apisocial_auth module should be installed along with social_auth_facebook. The best way to install and manage drupal modules is composer. 

Install composer like this as described here :

curl -sS | php
sudo mv composer.phar /usr/local/bin/composer

Then go to your Drupal site root or wherever your composer.json for the website is and run the following commands :

composer require drupal/social_api
composer require drupal/social_auth
composer require drupal/social_auth_facebook

Enable both the modules and go to the social_auth config (admin/config/social-api/social-auth) and click on the

 Facebook tab. This is what it would look like :

Login with facebook config

Substitute the values with the values from your facebook app. If you don't have an app, create one at this link

After you create an app, you should get your app id and app secret by clicking on settings > basic. 

This is how settings will look: 

You should not only have an app, you should also add a product. In this case 'Facebook Login' is the product. This is how the product settings look like :

Now you should be able to login with Facebook with the URL ''. To test on a local machine, add your local URL as well to the OAuth redirect URLs. 

Enjoy signing in with Facebook. Read the Facebook for developers blog for more info. Or log in and comment here.