Facebook is one of the most popular social media sites in the world. With its continuously growing number of registered users, it is likely your site's visitors already have a Facebook account. With the Facebook Connect authentication feature, you can allow visitors to use their Facebook accounts to register and log in to your site.
Allowing users to log in to your site with their Facebook account
Before setting up Facebook authentication, you need to create a Facebook App and connect the app to Kentico. See Connecting Kentico to social media for more information.
Set up your Facebook App to receive authentication requests from your Kentico website:
- Open the Facebook App editing page at https://developers.facebook.com/apps.
- Select your app and view the Settings tab.
- Type the domain that your website uses when connecting to Facebook into the App Domains field.
- Enter your website's URL into the Site URL field.
- Click Save Changes.
Facebook saves your app's settings.
Now you need to enable Facebook authentication in Kentico:
- Open the Settings application.
- Expand the Social media -> Facebook category.
- Select your site.
- This step is not required, but we do not recommend setting up Facebook authentication globally.
- Select the Enable login with Facebook check box.
- Copy your Facebook app's App ID and App Secret values into the corresponding settings in Kentico.
- Save the settings.
To add Facebook authentication functionality to your site, place the Facebook Connect logon web part onto a page.
- Edit the page in the Pages application.
- Select the Design tab.
- Add the Facebook Connect logon web part to a zone.
The web part displays the Login button to users who are not yet logged in. Clicking the button opens the Facebook Login dialog. The dialog asks you to enter your Facebook credentials and then requests permission to access your personal data. The required permissions depend on the settings in Social media -> Facebook. For more details about accessing personal information on Facebook, see Loading user information from Facebook profiles.
You may encounter one of these problems:
- The web part renders an error message when in Design mode.
- The web part doesn't display anything on the live site.
If you have these problems, double check your App ID and App Secret in settings. See Connecting Kentico to social media.
When a user signs in through a third-party authentication service for the first time, Kentico automatically creates a new account for the user. Learn more about managing users that sign in through a third-party authentication service.
The system also automatically populates the user's details fields in the system with the details from the user's Facebook profile. What data the system loads depends on how you set up loading user information from Facebook profiles.
Reference – Facebook integration settings
The following are settings that you can use to adjust the behavior of integrated Facebook features. These settings are located in Settings -> Social media -> Facebook.
Settings in this category determine which Facebook app to use for authenticating using Facebook. If you want to post to Facebook from Kentico, follow the procedure in Connecting Kentico to social media and Adding social media accounts.
We recommend selecting a site before adjusting the settings. Having a Facebook app connected to Kentico on a global level poses a security risk.
- App ID – a numeric ID of your Facebook App. You can find your App ID on the Facebook App editing page.
- App Secret – the key used to authenticate Kentico against the Facebook App. You can find your App secret on the Facebook App editing page.
Login with Facebook
- Enable login with Facebook – enable if you want your website users to log in with their Facebook account.
- Assign Facebook members to roles – when a new user logs in using Facebook, the system assigns the user to the roles entered here.
- Update users using their Facebook profile – allows you to load information from the user's Facebook profile and store it with the user's record in Kentico. This feature only works when users log in using their Facebook accounts. See Loading user information from Facebook profiles.
- Never - turns this feature off. User information that has already been downloaded is kept in the system.
- When they log in for the first time - downloads the user information only once, when they log in for the first time.
- Every time they log in - updates the user information every time they log in. However, this option doesn't update fields in Kentico that the user has already changed or fields that the system already filled using the information from the Facebook profile. For example, if an existing user gets married and changes her name on Facebook, her record in Kentico is not updated because the system downloaded her name from Facebook before.
- Mapping of Facebook user profile – determines how Kentico user fields match with Facebook profile fields.