How To : Get a user's gigya profile using their gigya uid - Gigya Drupal 8/9

This is technical document to serve an implementation reference by Developer. We assume that you have the gigya PHP SDK and gigya raas drupal 8 module installed in your project.

We’ve had multiple issues with getting user’s profiles or showing users information on the site – This is because of the limitation of the Gigya Client Side - Web SDK . The user information have to be queried server side and this is how:

Step-by-step guide

  • You need to instantiate the helper class:

    1
    2
    
      $helper = new Drupal\gigya\Helper\GigyaHelper();
      $api =  $helper->getGigyaApiHelper();
    
  • You can then fetch the user Gigya Account by calling fetchGigyaAccount($uid) this takes the gigya user id as a parameter

1
2
3
4
5
// The gigya UID is the drupal user uuid.
// Assuming the you have the user account interface loaded this can be fetched like this.

$uid = $account→uuid();
$gigya_user = $helper->getGigyaApiHelper()->fetchGigyaAccount($uid);
  • FetchGigyaAccount throws an exception:

    1
    
    Drupal\gigya\CmsStarterKit\sdk\GSApiException
    

    Remember to catch this in your code to avoid critical errors.