Gigya's integration with Livefyre makes it easy to implement Gigya's Customer Identity Management platform with your existing Livefyre implementation.
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.
The Demo code is available for download (see below).
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:
Now you can upload the demo to your site.
- 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.
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/jquery.*.js - jQuery libraries used for simplicity