Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

There are two methods allowing an external service to obtain a user id (uid) in the EthosCE system. A service may query by e-mail, or external user ID. Querying by e-mail may be used by any client, as a unique e-mail is required when creating a local EthosCE user. External ID is available only to clients with Single Sign-On (SSO), who may use a different unique key, than an e-mail address.

Query by E-mail

Query by E-mail
<?php
// Login to the site and request the access token
$curl = curl_init('http://your-domain.com/restws/session/token');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); // Your web service user credentials goes here.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$token = curl_exec($curl);
// The token looks like "q71OBx05wtECfjA0KmXf6wiktewrywNhkMZv-OcfyOA%"
// #1 Verify if user exists by sending a GET request to the system, searching by user 'mail' attribute
$curl = curl_init("http://your-domain.com/user.json?mail=external_user@dlc-solutions.com");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-CSRF-Token: $token", "Content-Type: application/json"));
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); //Your credentials goes here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
 
$json = curl_exec($curl);
$response = json_decode($json);
 
// A list of users matching criteria will be returned. If this list is empty, a user does not exist in EthosCE with the given e-mail address.
$list = $response->list;

Query by client External ID

When a user is created via an SSO call, an authentication map entry is created, keying a uid to a client external ID. The external ID is a pre-determined key, being sent in the SSO call.

Query by External ID
<?php
// Login to the site and request the access token
$curl = curl_init('http://your-domain.com/restws/session/token');
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); // Your web service user credentials goes here.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$token = curl_exec($curl);
// The token looks like "q71OBx05wtECfjA0KmXf6wiktewrywNhkMZv-OcfyOA%"
 
// #1 Verify if user exists by sending a GET request to the system, searching by user 'name' attribute
$curl = curl_init("http://your-domain.com/authmap.json?name=external_user_500");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-CSRF-Token: $token", "Content-Type: application/json"));
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "restws_webservice:webservice_password"); //Your credentials goes here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
 
$json = curl_exec($curl);
$response = json_decode($json);
 
// A list of users matching criteria will be returned. If this list is empty, the user does not exist in EthosCE with the given e-mail address.
$list = $response->list;

Successful Return

{"uri":"http://your-domain.com/authmap/200","id":"200","resource":"authmap"}
  • No labels