...hm="hmac-sha256",headers="(request-target) host date content-type content-length
Using C# code we are trying to connect world check API in order to get all groups "var client1 = new RestClient("https://rms-world-check-one-api-pilot.thomsonreuters.com/api-gateway-service-rest/api/v1/groups");"
var hmac = generateAuthHeader(dataToSign);
var auth = "Signature keyId=\"a4364e62-e58b-4b64-9c71-faead5417557\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\"" + hmac + "\"";
var client1 = new RestClient("https://rms-world-check-one-api-pilot.thomsonreuters.com/api-gateway-service-rest/api/v1/groups");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Connection", "keep-alive");
request.AddHeader("accept-encoding", "gzip, deflate");
request.AddHeader("Host", "rms-world-check-one-api-pilot.thomsonreuters.com");
//request.AddHeader("Postman-Token", "fe63f34e-6ef4-4553-957c-169c20b48d81,ad89d15f-1910-4550-ba4c-d9216fd5655f");
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Accept", "*/*");
//request.AddHeader("User-Agent", "PostmanRuntime/7.15.0");
request.AddHeader("Authorization", auth);
//request.AddHeader("Authorization", "Signature keyId=\"a4364e62-e58b-4b64-9c71-faead5417557\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\" + fpcXQ8jdAg1mWaGUSph0tE/ftjasjg2phaD3T5NKO4=\"");
request.AddHeader("Date", todayUTC);
IRestResponse response1 = client1.Execute(request);
Getting error in response : "StatusCode: Unauthorized, Content-Type: , Content-Length: -1)"
To genete Auth Header we are using below function:
public string generateAuthHeader(string dataToSign)
{
var signature = string.Empty;
using (var hmac = new HMACSHA256(Encoding.UTF8.GetBytes(apiSecret)))
{
var hash = hmac.ComputeHash(Encoding.UTF8.GetBytes(dataToSign));
signature = Convert.ToBase64String(hash);
}
return signature;
}
Please validate if above HMAC generation code is correct or not
Also please let me know if you need any further details