HMAC test strings and results problem

Hi, I am new to world-check api and trying to follow instructions first to generate the hmac signature. reading /documentation/schema-reference/security.html I found this example:
(request-target): post /v1/cases
host: rms-world-check-one-api.thomsonreuters.com
date: Tue, 07 Jun 2016 20:51:35 GMT
content-type: application/json
content-length: 88
{
"caseId": "my customer ID",
"name": "John Doe",
"providerTypes": ["WATCHLIST"]
}
with secret "1234" must return DA26D7F5BFF89A100D1A597AA015099FC55DD3130F023E952BFBE3A6949F322A but I am NOT receiving the same result.
I am sending this full string as follows:
ls_message="(request-target): post /v1/cases"+char(10)+"host: rms-world-check-one-api.thomsonreuters.com"+char(10)
ls_message+="date: Tue, 07 Jun 2016 20:51:35 GMT"+char(10)
ls_message+="content-type: application/json"+char(10)+"content-length: 88"+char(10)+"{"+char(10)+" ~"caseId~": ~"mycustomerID~","+char(10)
ls_message+=" ~"name~": ~"John Doe~","+char(10)+" ~"providerTypes~": [~"WATCHLIST~"]"+char(10)+"}"
Can you check what is wrong with the string?
I have tested the HMAC function at https://www.freeformatter.com/hmac-generator.html#ad-output with other strings and results from the function are correct, but with smaller strings. I don't know how to test with \n end of lines there.
Regards
Best Answer
-
Found the solution
Include this header
loo_xmlHTTP.setRequestHeader("Content-Type","application/json")
And use current date time.
Thanks for your help
0
Answers
-
Hi @asantibanez,
Please take a look at my answer to this previous question, as I point out, the documentation is incorrect...
Hope this helps,
Brian0 -
Thanks, I used Postman to follow the process and some part is working, at least reaching de HMAC result, but cannot make encode64 work as the examples on SEQ-1a.
I am obtaining from Postman and my software test the same result:
var hash = CryptoJS.HmacSHA256(dataToSign,environment["api-secret"]);
postman.setEnvironmentVariable("hash",hash)in my example is
487c2b186b9dd6e29455dd1840a1bd57c3725159cad96948b528ba0beb9bbb92
But not the rest of the function
return hash.toString(CryptoJS.enc.Base64);
I am receiving from my software and from
https://www.freeformatter.com/base64-encoder.html#ad-output the same output
NDg3YzJiMTg2YjlkZDZlMjk0NTVkZDE4NDBhMWJkNTdjMzcyNTE1OWNhZDk2OTQ4YjUyOGJhMGJlYjliYmI5Mg==
But postman returns
SHwrGGud1uKUVd0YQKG9V8NyUVnK2WlItSi6C+ubu5I=
Any hint on what to look for
Regards
Alfredo
0 -
Hi @asantibanez,
If the Postman code works without your edits (i.e. out-of-the-box), then it could be a number of items. I suggest you look at my example and follow those steps, you could be just one character off or note that the example uses the Production URL and not the Pilot URL, which means you will not get the same result using Postman with the Pilot URL.
What environment are you developing in?
Brian
0 -
I am using
rms-world-check-one-api-pilot.thomsonreuters.com on Postman, please remember that the hmac result is equal, where the URL is used, them trying to convert to base64 is the difference.
let me copy the code I am using
string hmac
HMAC = in_capi.of_Hmac(ls_Algorithm, datatosign, apisecret )
If IsNull( hmac) Then
MessageBox(in_capi.LastFunction + " Failed", &
in_capi.LastErrText, StopSign!)
Return
End If
lblb_hmac64=blob(hmac,encodingansi!)
hmac64=in_capi.of_blob_encode64(lblb_hmac64)//HERE IS THE PROBLEM, the string returned is different
//If I use the same string and try to encoded to base 64 with the public service
//https://www.freeformatter.com/base64-encoder.html#ad-output
//I receive the same result as this función used above. But is different from postman.
//I have not sent the GET
string authorisation = "Signature keyId=~"" + apikey + "~",algorithm=~"hmac-sha256~",headers=~"(request-target) host date~","
authorisation+="signature=~"" + hmac64 + "~""0 -
Hi @asantibanez,
Here is the corrected documentation to be updated in the next release...
HTTP request example
To illustrate all these requirements, given the following sample HTTP request:
POST /v1/cases HTTP/1.1 Host: rms-world-check-one-api.thomsonreuters.com Date: Tue, 07 Jun 2016 20:51:35 GMT Content-Type: application/json Content-Length: 88 { "caseId": "my customer ID", "name": "John Doe", "providerTypes": ["WATCHLIST"] }
the signing text used as input to the HMAC function would be:
(request-target): post /v1/cases host: rms-world-check-one-api.thomsonreuters.com date: Tue, 07 Jun 2016 20:51:35 GMT content-type: application/json content-length: 88 { "caseId": "my customer ID", "name": "John Doe", "providerTypes": ["WATCHLIST"] }
This example assumes LF line endings (‘\n’/
0x0A
), and no trailing line ending after the closing bracket in the payload body.Given the above signing text, if a secret key of “1234” is used, the computed HMAC-SHA256 value would be
224B73FC07571E60E8B8D9BAB8107C656D3171F346B96183C665FD4C5330B85D
when printed using hex encoding, orIktz/AdXHmDouNm6uBB8ZW0xcfNGuWGDxmX9TFMwuF0=
when printed using base64 encoding.The base64 representation is the value that will be included in the
Authorization
header. In this example, assuming an API key of4321
, the full HTTP request (with populatedAuthorization
header) that will be sent to the API would then be:POST /v1/cases HTTP/1.1 Host: rms-world-check-one-api.thomsonreuters.com Date: Tue, 07 Jun 2016 20:51:35 GMT Content-Type: application/json Content-Length: 88 Authorization: Signature keyId="4321",algorithm="hmac-sha256", headers="(request-target) host date content-type content-length", signature="Iktz/AdXHmDouNm6uBB8ZW0xcfNGuWGDxmX9TFMwuF0=" { "caseId": "my customer ID", "name": "John Doe", "providerTypes": ["WATCHLIST"] }
0 -
Hi, the base64 problem is solved. I found a link mentioning returns from hmac can be in HEx format, so calculation of base64 must take note of it. Now I have the same base64 result and I can continue with the test.
new problem, unathorized, same endpoint, same headers for date and autorization
My software and postman have the same values for:
datatosign is
(request-target): get /v1/groups
host: rms-world-check-one-api-pilot.thomsonreuters.com
date: Tue, 11 Apr 2017 13:51:28 GMTautorisation is
Signature keyId="6f23c447-b6d8-4291-acda-a5f7e8fb48c3",algorithm="hmac-sha256",headers="(request-target) host date",signature="pBFw2eDXR2Npi18jImj+o9Mn/leo/OsDn8MXlh0VlSA="
dates is
Tue, 11 Apr 2017 13:51:28 GMT
endpoint is
https://rms-world-check-one-api-pilot.thomsonreuters.com/v1/groups
Call is this way
OleObject loo_xmlhttp
long ll_status_code
loo_xmlhttp = CREATE oleobject
loo_xmlhttp.ConnectToNewObject("Msxml2.XMLHTTP.6.0")
loo_xmlhttp.open ("GET", requestendpoint, false)
loo_xmlHTTP.setRequestHeader("Authorization",authorisation)
loo_xmlHTTP.setRequestHeader("Date",dates)
loo_xmlhttp.send()
ls_status_text = loo_xmlhttp.StatusText
ll_status_code = loo_xmlhttp.StatusI have debugged and checked every variable.
Any hint? some other header missing?
Is there a way that Thomson Reuters can debug my session or verify if something is been sent incorrectly.
Regards
Alfredo
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 685 Datastream
- 1.4K DSS
- 615 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 252 ETA
- 556 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 652 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 228 TRKD
- 917 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛