You are here

public static function ClientsServicesDrupal::getToken in Web Service Clients 6

Prepares a hashed token for the service, based on current time, the required service and config values; serviceKey and serviceDomain t

Parameters

$connection: stdClass: A service connection as returned by Clients::load()

$serviceMethod: string: Name of service method to access

Return value

array a valid token

2 calls to ClientsServicesDrupal::getToken()
ClientsServicesDrupal::fetch in backends/clients_drupal/clients_drupal.inc
Gets raw data from service call
ClientsServicesDrupal::getUser in backends/clients_drupal/clients_drupal.inc
Connects to Drupal Services and logs in the user provided in the config. Returns a session for the user. @todo needs error catching in case service is down

File

backends/clients_drupal/clients_drupal.inc, line 38
Defines methods and calls to Drupal services

Class

ClientsServicesDrupal

Code

public static function getToken($connection, $serviceMethod) {
  $timestamp = (string) time();
  $nonce = uniqid();
  $hashParameters = array(
    $timestamp,
    $connection->configuration['domain'],
    $nonce,
    $serviceMethod,
  );
  $hash = hash_hmac("sha256", implode(';', $hashParameters), $connection->configuration['servicekey']);
  return array(
    'hash' => $hash,
    'domain' => $connection->configuration['domain'],
    'timestamp' => $timestamp,
    'nonce' => $nonce,
  );
}