How to generate signature by cURL alone without Postman

I'm trying to access WC1 API via cURL command.
When I use Postman, it responds 200 properly, and using that signature cURL properly responds.
However I'm stuck on generating signature by cURL alone.
Can I get a cURL command sample to generate signature (and timestamp) using my secret access key?

Here's what I tired (using signature generated by Postman) - it works only for 1 minute.

$ curl -X GET \
https://rms-world-check-one-api-pilot.thomsonreuters.com/v1/groups \
 -H 'Authorization: Signature keyId="f63fc14f-981f-4bba-95e0-eb65800e8126",algorithm="hmac-sha256",headers="(request-target) host date",signature="xtijpe/hMeEP<removed>=="' \
-H 'Date: Sun, 04 Aug 2019 07:53:21 GMT' \

Best Answer

  • naoto.tatemichi
    Answer ✓

    Thanks @Irfan.Khan
    Now I made it in PHP which works fine.

    $secret_file = '/var/www/api_secret.txt';


    $api_key = "YOUR_API_KEY";
    $secret = file_get_contents($secret_file);
    $gateway_url = "/v1/";
    $gateway_host = "rms-world-check-one-api-pilot.thomsonreuters.com";
    $time_gmt = gmdate("D, d M Y h:i:s") . " GMT";


    $dataToSign = "(request-target): get " . $gateway_url . "groups\n" . "host: " . $gateway_host . "\n" . "date: " . $time_gmt;


    $hmac = base64_encode(hash_hmac('sha256', $dataToSign, $secret, true));


    $authorisation = "Signature keyId=\"" . $api_key . "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\"" . $hmac . "\"";



    echo $authorisation;

Answers