Python Project gives 401 Error when using GetTopLevelGroupRequest. Require Python sample code to ...

...generate hmac or signature header. Python signature and Postman signature doesn't match.
Hi,
I have been trying to create a sample API integration project using Python. I have tried to follow the steps as in Postman and as in the Java Sample World Check Application from the Downloads section.
When I run the code, I keep getting the 401 Unauthenticated Error. I believe it is due to the incorrect generation of the hmac. When trying with the same date variable in Postman and Python, the signatures don't match.
Could you please provide a sample code which would help me generate the proper signature so that I can get a groupId as the response? (The response is 200 when doing the same from POSTMAN)
P.S. I have tried using one of the sample code for provided for Python from one of the solutions posted here. That does not seem to work. I tried different methods for generating a similar hmac as CryptoJS does, but it did not work out for me.
Thanks,
Aman
Best Answer
Answers
-
Request Headers:
{'User-Agent': 'python-requests/2.24.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Authorization': 'Signature keyId="8908a09e-5118-4087-8413-25e20c3867b3",algorithm="hmac-sha256",headers="(request-target) host date",signature="rGGF4v6LRG5h6Cucl7cgzEYpW4OC97xwYueDP3KjYtk="', 'Date': 'Mon, 21 Sep 2020 01:25:40 GMT'}
Response Headers:
{'Strict-Transport-Security': 'max-age=15552000, includeSubdomains', 'Authorization': 'WWW-Authenticate: Signature realm="World-Check One API",algorithm="hmac-sha256",headers="(request-target) host date content-type content-length"', 'Date': 'Mon, 21 Sep 2020 01:25:41 GMT', 'Server': '""', 'Content-Length': '0', 'Age': '430', 'Via': 'HTTPS/1.1 BFAMPHKGWCG01'}0 -
datatosign = "(request-target): get " + gatewayurl + "groups\n" + \
"host: " + gatewayhost + "\n" + \
"date: " + date + "\n"0 -
gatewayurl = "/v1/"
gatewayhost = "rms-world-check-one-api-pilot.thomsonreuters.com"dataformat = ("%a, %d %b %Y %H:%M:%S GMT")
datenow = time.gmtime()
date = time.strftime(dataformat, datenow)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
- 651 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 中文论坛