"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

authentication fails

 

=== PHP ===

[php]<?php/** * Questions: * The webservice url is vws.vuforia.com ??? */ini_set('display_errors', '1');error_reporting(-1);$VUFORIA_WEBSERVICE_BASEURL = "vws.vuforia.com";$contentType = "application/json";//$contentType = "multipart/form-data";//$clientAccessKey = "af8531bdbc4e16301ce161b71f40519cd362d815";//$clientSecretKey = "65fc6958a85c20f25dde1eee64fac4d4c0ef9ea5";$serverAccessKey = "5dff4c7b228a19389e1038789a3cdf89be3a2d71";$serverSecretKey = "dce9683e1188befeb3e867193fc81c16d574bbc2";$imageTestUrl = "http://img4-2.cookinglight.timeinc.net/i/Oxmoor/oh3360p161-all-american-chili-l.jpg";$imageEncodedBase64 = getImageData($imageTestUrl);$requestBody = createRequestBodyJson('oh3360p161-all-american-chili-l.jpg', "400", $imageEncodedBase64);//echo "Request body:".$requestBody;date_default_timezone_set('America/New_York');//date_default_timezone_set('GMT');$date = date("D, d F o h:i:s e");$lf = "\n"; //'U+000A'//$lf = PHP_EOL;//$lf = 'U+000A';//Signature = Base64(HMAC-SHA1(server_secret_key, StringToSign ) ) ;//StringToSign =//HTTP-Verb + "\n" +//Content-MD5 + "\n" +//Content-Type + "\n" +//Date + "\n" +//Request-Path;$stringToSign = "POST" . $lf .        md5($requestBody) . $lf .        $contentType . $lf .        $date . $lf . //e.g.:Date: Mon, 23 April 2012 12:45:19 GMT        "/targets";$signature = base64_encode(hash_hmac('sha1', $stringToSign, $serverSecretKey));$authString = "VWS " . $serverAccessKey . ":" . $signature;$headerArray = array(    'POST /targets HTTP/1.1',    'Authorization: ' . $authString,    'Host: ' . $VUFORIA_WEBSERVICE_BASEURL,    'Date: ' . $date,    'Content-Type: ' . $contentType,    'Request-Path: ' . '/targets');print_r($headerArray);postIt($requestBody, $headerArray);/* * POST /targets HTTP/1.1Host: vws.vuforia.comDate: Mon, 23 April 2012 12:45:19 GMTAuthorization: VWS df8d23140eb443505c0661c5b58294ef472baf64:jHX6oLeqTXpynyqcvVC2MSHarhUContent-Type: application/json{“name”:”test”,“width”:20,“image”:”…base64 encoded image data…”,“application_metadata”:”… base64 encoded data..”} */function postIt($requestBody, $headerArray){    global $VUFORIA_WEBSERVICE_BASEURL;    $ch = curl_init();    $timeout = 10;    curl_setopt($ch, CURLOPT_URL, 'https://'. $VUFORIA_WEBSERVICE_BASEURL . '/targets');    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);    curl_setopt($ch, CURLOPT_POST, 1);    curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);    curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArray);    //curl_setopt($ch, CURLINFO_HEADER_OUT, 1);    $data = curl_exec($ch);    $response = curl_getinfo($ch);    if (curl_errno($ch)) {        print 'CURL ERROR '.curl_error($ch);        print 'ERROR #' . curl_errno($ch);    } else {        curl_close($ch);    }    echo PHP_EOL ."Response:" . print_r($data, true);        echo PHP_EOL.PHP_EOL."Info:" .print_r($response, true);}function createRequestBodyJson($name, $width, $image) {    $body = array(        'name' => $name,        'width' => floatval($width),        'image' => $image    );    return json_encode($body);}function getImageData($url) {    return base64_encode(file_get_contents($url));}?>

[/php]

 

 

DavidBeard

Tue, 09/25/2012 - 18:22

To confirm, have you been able to execute any other provisioning requests or queries - or are they all returning this error?

Also can you post, or PM me, your request body, so that I can validate it?

DavidBeard

Tue, 09/25/2012 - 20:16

Try revising the format of your Date field. That appears to be the culprit. You should use GMT and the abbreviated form of the month, without punctuation (i.e. Sep ).

Per agreement with Roy I am re posting here from an email thread:

Please have some look at it as I am out of ideas. Havent tried any other methods as this is the first part of our use case (to upload photos)

Please look in the source of the previous post - for some reason nothing is showing but its all there...thanks!

Hello,

Could you tell me what was the solution, because im stuck with the same problem. 

Im still trying but always get something like this: {"result_code":"AuthenticationFailure","transaction_id":"7c9ebae3e7a5403b8b91714ef84203e7"}

Hi David, thanks for the fast reply! After double checking the files from the link below and the description on the "setting up the API" page did I see that the file SignatureBuilder is not included in the java sample code. Is this file obsolete or am I missing something? Oh, ..

Creadsmedia

Tue, 01/29/2013 - 11:29

I have same problem.

I'm using php and curl and this is my request and respose:

@ Creadsmedia:

you can have a look in this thread (where some PHP code snippets  from various developers have been shared):

https://developer.vuforia.com/forum/general-discussion/vws-authorization-problem