So I was able to create Vuforia Cloud Targets and they work fine even attaching metadata, Now when I try to make an http request DELETE it fails returning 401. PLEASE HELP!
this is my code so far:
public string secret_key; public string access_key; public string targetID
public void DeleteTarget() { Debug.Log("Initiating deletion"); StartCoroutine(DeleteRequest()); } IEnumerator DeleteRequest() { string url = @"https://vws.vuforia.com/targets/" + targetID; string date = string.Format("{0:r}", DateTime.Now.ToUniversalTime()); ; string auth = GetAuth(url, date);
UnityWebRequest uwr = UnityWebRequest.Delete(url); uwr.SetRequestHeader("host", "vws.vuforia.com"); uwr.SetRequestHeader("date", date); // uwr.SetRequestHeader("Content-Type", ""); uwr.SetRequestHeader("Authorization", auth);
yield return uwr.SendWebRequest();
if (uwr.isNetworkError || uwr.isHttpError) { Debug.Log("Error While Sending: " + uwr.error); Debug.Log(uwr.responseCode); } else { Debug.Log("Deleted"); } }
string GetAuth(string requestPath, string date) { string httpAction = "DELETE"; string contentType = ""; string content = "";
MD5 md5 = MD5.Create(); pmd5 = md5; byte[] contentMD5bytes = md5.ComputeHash(System.Text.Encoding.ASCII.GetBytes(content)); pcontentMD5bytes = contentMD5bytes; string stringToSign = string.Format("{0}\n{1}\n{2}\n{3}\n{4}", httpAction, contentMD5bytes, contentType, date, requestPath); pstringToSign = stringToSign;
HMACSHA1 sha1 = new HMACSHA1(System.Text.Encoding.ASCII.GetBytes(secret_key)); byte[] sha1Bytes = System.Text.Encoding.ASCII.GetBytes(stringToSign); MemoryStream stream = new MemoryStream(sha1Bytes); byte[] sha1Hash = sha1.ComputeHash(stream); string signature = System.Convert.ToBase64String(sha1Hash);
string aa = string.Format("VWS {0}:{1}", access_key, signature);
return aa; }
Hello,
Hello,
Non-warrantied scripts provided by a Vuforia Engine forum user: https://developer.vuforia.com/forum/cloud-recognition/vws-requests-c-unity-authentication#comment-67342
https://github.com/taylordigital13/VuforiaTools
Thanks,
Vuforia Engine Support