Facebook authentication

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

Prerequisites

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:

  1. Open the Facebook App editing page at https://developers.facebook.com/apps.
  2. Select your app and view the Settings tab.
  3. Type the domain that your website uses when connecting to Facebook into the App Domains field.
  4. Enter your website’s URL into the Site URL field.
  5. Click Save Changes.

Facebook saves your app’s settings.

Setting up your Facebook app to enable users to log in to your website using their Facebook account

Now you need to enable Facebook authentication in Kentico:

  1. Open the Settings application.
  2. Expand theSocial media -> Facebook category.
  3. Select your site.
    • This step is not required, but we do not recommend setting up Facebook authentication globally.
  4. Select the Enable login with Facebook check box.
  5. Copy your Facebook app’s App ID and App Secret values into the corresponding settings in Kentico.
  6. Save the settings.

To add Facebook authentication functionality to your site, place the Facebook Connect logon web part onto a page.

  1. Edit the page in the Pages application.
  2. Select the Design tab.
  3. 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.

Facebook app

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.