Livefyre

Skip to end of metadata
Go to start of metadata

 

Gigya's integration with Livefyre makes it easy to implement Gigya's Customer Identity Management platform with your existing Livefyre implementation.

Solution Overview

The integration is based on the Livefyre Developer Documentation and closely follows the process outlined in the Identity Integration Section. We recommend that you reference both this guide as well as the Livefyre Developer Documentation when integrating Gigya and Livefyre on your website.

The integration includes both client-side and server-side components:

  • On the client side, Livefyre's Comments app is loaded on the page.
  • When users authenticate with Gigya, triggered from either the Comments app or an outside source on the page, the integration makes a server-side call (in server/ajax/token-endpoint.php) to the Livefyre network to authorize the Gigya user with Livefyre, and provide that user with an access token, which is used to interface with the Livefyre commenting plugin.
  • Once the user is authenticated with both Gigya and Livefyre, he or she may comment on the page using their Gigya user profile.
  • The logged-in state of the user on the page is kept in sync between both Gigya and Livefyre, such that when a user logs in or out via Gigya or Livefyre, both services recognize the updated state of the user.

The most salient point of the solution (in server/ajax/token-endpoint.php:16-40) is the presence of functions to conform the Gigya UID into Livefyre-compliant URL-safe Base 64 user IDs and vice versa. This solution is language-agnostic as it deals with string translations to use only a subset of the Base 64 Gigya UIDs. The solution replaces the Livefyre-unsafe characters ‘+’ and ‘/’ with ‘-’ and ‘_’, respectively, and removes the Base 64 ‘=’ padding characters. The function urlsafe_base64_to_base64 reverses these translations.

Running A Demo

In the downloadable demo we use a Registration-as-a-Service screenset for the authentication, but traditional social login would work the same way. Users can login from either the Login link at the top of the page or via the Livefyre plugin. The links within the Livefyre plugin are also integrated with the Gigya authentication platform. The "Edit Profile" link in the Livefyre plugin will trigger Gigya's Registration-as-a-Service Profile screen, and the "Sign Out" link will sign the user out of both Livefyre and Gigya.

 

In order for the demo to function, you must have third-party cookies enabled.

The Demo code is available for download (see below).

Implementation Instructions

The source code for the demo is available here: livefyre.zip

To try out the demo on your own site, download the code and edit the file config/config.php to insert your site domain and your Gigya and Livefyre API configurations:

define('SITE_DOMAIN', '<INSERT-YOUR-WEBSITE-DOMAIN-HERE>');
define('SESSION_EXPIRATION', 2592000); // 30 days
define('GIGYA_API_KEY', '<INSERT-YOUR-GIGYA-API-KEY-HERE>');
define('GIGYA_SECRET', '<INSERT-YOUR-GIGYA-SECRET-KEY-HERE>');
define('LIVEFYRE_NETWORK', '<INSERT-YOUR-LIVEFYRE-NETWORK-HERE>');
define('LIVEFYRE_NETWORK_KEY', '<INSERT-YOUR-LIVEFYRE-NETWORK-KEY-HERE>');
define('LIVEFYRE_SITE_ID', '<INSERT-YOUR-LIVEFYRE-SITE-ID-HERE>');
define('LIVEFYRE_SITE_KEY', '<INSERT-YOUR-LIVEFYRE-SITE-KEY-HERE>');

Now you can upload the demo to your site.

Notes:

  • The demo source code includes Livefyre's PHP library in the livefyre/server/lib/livefyre-php-utils folder and the PHP-JWT library in the livefyre/server/lib/php-jwt folder. To use the latest versions of these libraries, see Livefyre PHP and PHP-JWT on Github.
  • The demo source code is configured with Gigya's Registration-as-a-Service product. If RaaS is not enabled on the API key you have set in config.php, you will need to modify the example to use your own social user registration and profile screens.

Demo Files

The integration demo includes the following files:

  • index.php - Used to display Livefyre Comments app and Gigya authentication
  • config/config.php - Configuration file to store your Gigya and Livefyre API credentials
  • server/lib/gigya/GSSDK.php - Gigya's PHP SDK
  • server/lib/livefyre-php-utils/ - Livefyre's PHP library files. The library is available in various other languages from Livefyre.
  • server/ajax/token-endpoint.php - Used to validate the Gigya login and trigger the Livefyre login
  • client/js/init.js - Main JavaScript file used to handle Gigya and Livefyre client-side authentication
  • client/js/jquery.*.js - jQuery libraries used for simplicity