Obtaining access token

Adi Heymann -

To get your API access details, use the Cedato Dashboard. Under Network Settings->Platform API Key generate, you will be able to generate or regenerate your client ID and client secret string. 

The client application uses the access token it received in every subsequent request to the Platform API WS in a special header:

Authorization: bearer DaRfdfaR...MzYjw

Requesting a token:

POST /api/token

Headers:
accept: application/json
api-version: 1
authorization: Basic <base64(access-key:client-secret)>
content-type: application/x-www-form-urlencoded

Request body:

grant_type=client_credentials

cURL example:

curl --request POST 
 --url https://api.cedato.com/api/token 
 --header 'accept: application/json' 
 --header 'api-version: 1' 
 --header 'authorization: Basic <base64-client-id:client-secret>' 
 --header 'content-type: application/x-www-form-urlencoded'

Create Oauth Token Script

<?php
define('CEDATO_API_ENDPOINT_URL''https://api.cedato.com/api/');
define('CEDATO_API_ID_CLIENT''123456789');
define('CEDATO_API_ID_SECRET''123456789');
$res = curl_init();
curl_setopt_array($resarray(
CURLOPT_URL => CEDATO_API_ENDPOINT_URL.'token',
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => http_build_query(array(
'grant_type' => 'client_credentials'
)),
CURLOPT_HTTPHEADER => array(
'accept: application/json',
'api-version: 1',
'authorization: Basic
'.base64_encode(CEDATO_API_ID_CLIENT.':'.CEDATO_API_ID_SECRET),
'content-type: application/x-www-form-urlencoded'
),
CURLOPT_SSL_VERIFYHOST => FALSE,
CURLOPT_SSL_VERIFYPEER => FALSE
));
$response = curl_exec($res);
curl_close($res);
var_dump($response);
?>
 

Receiving a token response 

The API server sends back a response similar to this:

{

"access_token": "DaRfdfaR...MzYjw",

"token_type": "bearer",

"expires_in": 3600, //In seconds

}

Valid API requests must include the sent token as part of the authorization header

Have more questions? Submit a request

0 Comments

Article is closed for comments.