Add new comment

How to login to Drupal with Facebook account

I'm a big fan of single-sign on (SSO) systems. Keeping one account secure and up-to-date is much easier than dealing with hundreds of logins and passwords for hundreds of sites. Fortunately, many of our clients agree with that and introduce single-sign on mechanisms on their sites and apps.

The most popular choice for SSO nowadays is to use Facebook as identity provider. Fortunately, Facebook authentication is quite well supported by Drupal.

There are many ways to integrate Drupal with Facebook authentication. We usually use oAuth protocol and OAuthConnector module. Below you can find a list of steps that will guide you through configuration of this module. Note that this is not a complete, step-by-step tutorial on integrating Drupal with Facebook. If you need more detailed guidance or help, contact us to get our (really affordable :)) consulting services.

Drupal configuration

  1. First, you must install and enable OAuthConnector with all requirements.
  2. On /admin/structure/oauthconnector page, add Facebook using "add provider from preset" option
  3. Set OAuth Consumer Key and OAuth Consumer Secret based on data read from Facebook website (see below)

After saving above configuration, you will see a link to connect with Facebook in "Connect URL" column of /admin/structure/oauthconnector page; use this link to create your own "connect with Facebook" button. If you get an error like:

SSL certificate problem: unable to get local issuer certificate

you need to define SSL root certificate for CURL - open php.ini. Find option:

curl.cainfo=<path-to-cacert.pem>

where <path-to-cacert.pem> means path to file with certificates, which can be downloaded from http://curl.haxx.se/ca/cacert.pem (note: if you don't trust the linked file - and you definitely should not trust it, especially for production use - generate your own, based on information available on the Web). After making this change, restart Apache.

Facebook configuration

To configure Facebook, you must:

  1. Create a new app at https://developers.facebook.com/apps
  2. Edit created app, find App ID and App Secret and use them as OAuth Consumer Key and OAuth Consumer Secret in Drupal provider configuration
  3. Add your domain to App Domains option
  4. Add URL to your site (like http://www.mysite.com/) to Website with Facebook Login (note: URL to your site must be a subdomain of one of App Domains).

After saving your changes and waiting a few minutes, you will be able to log in to your Drupal site with Facebook account. Use the URL which can be found in  /admin/structure/oauthconnector . You can also enable and use "connector" block, which is available in admin/structure/block .

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.