Authorization issue while calling worldcheck one API

Hi,
Greetings. I executed the sample program provided by Refinitiv world check id. The program was successful and working fine from my lab which is based in other location. I'm tried to execute the same program in my local environment, I'm always receiving the 401 error. I used same apikey and secret key.
I do not see any proxy issue as well with local system. is there anything to do with the timezone.
I tried to execute the sample request through postman. I received same error over postman as well. I'm not sure why the authorization failed with the same key and secret.
Please help me to resolve this issue. Please let me know if you want me to share the entire program.
Error Message :
15:31:03.025 [main] DEBUG org.springframework.web.client.RestTemplate - GET request for "https://rms-world-check-one-api-pilot.thomsonreuters.com/v1/reference/profile/e_tr_wci_4277049" resulted in 401 (null); invoking error handler
Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 401 null
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:94)
Sample Program:
public static final String PROFILE_CHECK_API_ENDPOINT="https://rms-world-check-one-api-pilot.thomsonreuters.com/v1/reference/profile/e_tr_wci_4277049";
public static void main(String[] args) throws Exception {
getAuthorization();
}
public static void getAuthorization() throws KeyManagementException, NoSuchAlgorithmException, JsonParseException, JsonMappingException, IOException {
System.out.println("Inside Authorization Block!!!");
Date now = new Date();
// format for date string Mon, 27 Mar 2017 15:19:36 GMT
DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
df.setTimeZone(TimeZone.getTimeZone("GMT"));
String date = df.format(now);
String gatewayurl = "/v1/";
String gatewayhost = "rms-world-check-one-api-pilot.thomsonreuters.com";
String apikey = "";
String apisecret = "";
String dataToSign = "(request-target): get " + gatewayurl + "reference/profile/e_tr_wci_4277049" + "\n" + "host: " + gatewayhost + "\n" + "date: " + date;
String hmac = generateAuthHeader(dataToSign, apisecret);
String authorisation = "Signature keyId=\"" + apikey + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date\",signature=\"" + hmac + "\"";
System.out.println(" Authorization *** " + authorisation);
System.out.println("DATA TO SIGN " + dataToSign);
System.out.println(" HMAC " + hmac);
getApData(authorisation, date, PROFILE_CHECK_API_ENDPOINT);
}
public static String generateAuthHeader(String dataToSign, String secret)
{
String hash = "";
try {
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), "HmacSHA256");
sha256_HMAC.init(secret_key);
hash = Base64.encodeBase64String(sha256_HMAC.doFinal(dataToSign.getBytes()));
}
catch (Exception e){
System.out.println("Error");
}
return(hash);
}
public static void getApData(String authorisation,String date,String url) throws JsonParseException, JsonMappingException, IOException{
RestTemplate rest = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", authorisation);
headers.set("Cache-Control", "no-cache");
headers.set("date", date);
HttpEntity<String>httpEntity = new HttpEntity<String>("",headers);
ResponseEntity<String> responseEntity = rest.exchange(url, HttpMethod.GET,httpEntity, String.class);
int status = responseEntity.getStatusCodeValue();
System.out.println("status *** " + status);
String response = responseEntity.getBody();
ObjectMapper mapper = new ObjectMapper();
Object res = mapper.readValue(response, Object.class);
String intended = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(res);
System.out.println("response *** " + intended);
}
Best Answer
-
I've debugged this issue based on the earlier queries. The reason is due to the NTP syncup. I'm able to execute the API after NTP syncup of my windows machine. This is working fine now.
This can be closed now.
0
Answers
-
Thank you for the remarks on resolution. I am accepting the anser to be correct!
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
- 687 Datastream
- 1.4K DSS
- 622 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
- 255 ETA
- 557 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
- 276 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
- 680 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
- 194 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 91 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛