Create an Authentication Endpoint in the Customer Portal

The Live Experience widget requires a valid authentication token (a JSON web token, or JWT) to be able to establish a connection from inside the Customer Portal back to Live Experience.

The Customer Portal needs to provide a REST endpoint that allows the code running in the browser to retrieve a valid JWT from the Live Experience service and provide that JWT to the Live Experience widget.

You add an authentication endpoint to your Customer Portal by creating a custom controller in the Customer Portal.

See Custom Controllers.

  1. For your Live Experience authentication endpoint, create a new custom controller in your Customer Portal called LX.php in /cp/customer/development/controllers.
    Use the following code sample for LX.php:
    <?php 
    namespace Custom\Controllers;
    class LX extends \RightNow\Controllers\Base
    {
     //This is the constructor for the custom controller. Do not modify anything within
     //this function.
     function __construct()
     {
     parent::__construct();
     }
     function auth () {
     load_curl();
     $curl = curl_init();
     curl_setopt_array($curl, array(
     CURLOPT_URL => "https://<LX_DOMAIN>/auth/apps/api/access-token?grant_type=client_credentials&state=0&scope=optional&nonce=221",
     CURLOPT_RETURNTRANSFER => true,
     CURLOPT_SSL_VERIFYPEER => false,
     CURLOPT_SSL_VERIFYHOST => false,
     CURLOPT_ENCODING => "",
     CURLOPT_MAXREDIRS => 10,
     CURLOPT_TIMEOUT => 30,
     CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
     CURLOPT_CUSTOMREQUEST => "GET",
     CURLOPT_POSTFIELDS => "",
     CURLOPT_HTTPHEADER => array(
     "Accept: application/json",
     "Authorization: Basic " . base64_encode("<CLIENT_ID>:<CLIENT_SECRET>"),
     "Origin: https://<RNOW_DOMAIN>/",
     "cache-control: no-cache"
     ),
     ));
     $response = curl_exec($curl);
     $err = curl_error($curl);
     curl_close($curl);
     if ($err) {
     echo "cURL Error #:" . $err;
     }
     else {
     echo $response;
     }
     }
    }
    • Replace <CLIENT_ID> with the client ID of the application you created earlier.
    • Replace <CLIENT_SECRET> with the client secret of the application you created earlier.
    • Replace <LX_DOMAIN> with the fully qualified domain name of the Live Experience region your tenant is located in: US (Phoenix): live.oraclecloud.com or EMEA (Frankfurt): emea.live.oraclecloud.com
    • Replace <RNOW_DOMAIN> with the fully qualified domain name of your Oracle Service Cloud site.
  2. When you are done, save the file and upload it back to the server with WebDAV.