This article will provide a step-by-step guide to configuring the Facebook login feature in Liferay Portal.
Create Facebook Developer Account
To begin, you will need two facebook accounts; that is, a regular facebook account and a developer facebook account. To obtain a developer account,
- Sign into facebook. using the regular facebook account.
- Navigate to developers.facebook.com
- Click the "Register Now" button in the top right corner of the screen.
- Follow the prompts until you have a developer's account
Configure Virtual Host
In addition to the Facebook accounts, a virtual host will also be required. In Windows, this can be accomplished by:
- Navigating to C:\Windows\System32\drivers\etc
- appending "127.0.0.1 [host name].com" to the hosts file.
For this article, we will use lportal.com.
At this point, we are ready to set up Facebook authentication.
Create Facebook Application
The first step is to create a Facebook application that we'll use to sign in.
- Go to developers.facebook.com and log in with you developer account.
- In the horizontal menu at the top of the screen, click the "Apps" option.
- Click "Create New App."
- In the pop-up that apears, give the app a name and select any category for the app.
- Fill in the captcha security check
- At this point, you will be taken to a screen that shows the configuration options for your new app. Congratulations, your app is created!
- In the box entitled "Basic Info," make sure "Sandbox Mode" is disabled.
- Check "Website with Facebook Login" and type "http://lportal.com:8080" when asked for a URL.
- Click "Save Changes."
Note: Below the title of your app is listed the "App ID" and the "App Secret." You will need these two items for configuring Liferay to authenticate with Facebook.
Finally, we will configure Liferay to use Facebook to authenticate users
Note: Remember to replace lportal.com with the virtual host you created in your environment.
- Start a Liferay 6.1 bundle.
- Navigate to http://lportal.com:8080.
- As the administrator, go to Control Panel/Portal Settings/Authentication and click "Facebook" in the horizontal menu.
- Check the "Enabled" checkbox.
- Input the following into the fields:
The Application ID of your facebook app.
The application secret of your facebook app.
OAuth Authentication URL:
OAuth Token URL
Now, simply sign in using the Facebook feature in the Sign In Portlet.
- Log out as the administrator
- Click the top right if necessary to access the sign in portlet. Click "Facebook."
- In the pop-up, input the facebook credentials of the regular account.
- You will be asked to allow the app you created as a facebook developer to have access to your account. Allow it.
Once this is approved, you will be logged into Liferay as a newly created facebook user.
If you are getting an "Invalid Redirect Error", re-check the authentication settings. Make sure that the redirect url is using the virtual host that was created above.
Subscriber Exclusive Content
A Liferay Enterprise Subscription provides access to over 1,500 articles that include best practices, troubleshooting, and other valuable solutions. Sign in for full access.Sign In