By PortoEditora
on Mon, 10/17/2016 - 10:21
Hello!
I'm trying to use the Image Recognition Query service, however I keep getting this response "WARNING: Authentication error: Unable to respond to any of these challenges: {vws=WWW-Authenticate: VWS} {"transaction_id":"ceba246ba06144c986427168b6bf6314","result_code":"AuthenticationFailure"}".
I've used one of the VWS API Java examples and adapted to this service. Below you can find the code.
public class VuforiaServiceTest { private final String serviceURL = "https://cloudreco.vuforia.com/v1/query"; private final String accessKey = "access_key"; private final String secretKey = "secret_key"; private final File testFilesDirectory = new File("path_to_images_directory"); private final File[] testFiles = testFilesDirectory.listFiles(); private boolean postImageForTesting(File image) throws URISyntaxException, ClientProtocolException, IOException, JSONException { //CREATE REQUEST HttpPost postRequest = new HttpPost(); //SET REQUEST URL postRequest.setURI(new URI(serviceURL)); //CREATE AND SET REQUEST BODY JSONObject requestBody = new JSONObject(); byte[] imageData = FileUtils.readFileToByteArray(image); requestBody.put("image", Base64.encodeBase64String(imageData)); postRequest.setEntity(new StringEntity(requestBody.toString())); //SET REQUEST HEADERS postRequest.setHeader(new BasicHeader("Date", DateUtils.formatDate(new Date()).replaceFirst("[+]00:00$", ""))); System.out.println(DateUtils.formatDate(new Date()).replaceFirst("[+]00:00$", "")); postRequest.setHeader(new BasicHeader("Content-Type", "multipart/form-data")); postRequest.setHeader(new BasicHeader("Accept", "application/json")); SignatureBuilder sb = new SignatureBuilder(); postRequest.setHeader("Authorization", "VWS " + accessKey + ":" + sb.tmsSignature(postRequest, secretKey)); System.out.println("VWS " + accessKey + ":" + sb.tmsSignature(postRequest, secretKey)); //CREATE HTTP CLIENT AND EXECUTE REQUEST HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(postRequest); String responseBody = EntityUtils.toString(response.getEntity()); System.out.println(responseBody); return true; } public static void main(String[] args) throws URISyntaxException, ClientProtocolException, IOException, JSONException { VuforiaServiceTest test = new VuforiaServiceTest(); Date testStart = new Date(); for (File testFile : test.testFiles) { if (testFile.isFile()) if(test.postImageForTesting(testFile)); } Date testEnd = new Date(); long duration = testEnd.getTime() - testStart.getTime(); duration = TimeUnit.MILLISECONDS.toSeconds(duration); System.out.println(duration); } }
Some help on how to solve this problem would be appreciated.
Best regards!
had any luck?
had any luck?
Hello!
Hello!
I have the same problem. And I'm using the client access keys when attempting to access the Vuforia Web Query API, but without success.
Please, look: is there a different method in authentication to Vuforia Web Query API?