none
microsoft azure storage queue authentication stringtosign error

    Question

  • Hi Team,

    I am trying to create a storage queue from the javscript (using rest api)

    To create a queue, i need to generate the authentication token.

    For generating the authentication token, i used the following method

    function GetToken()
    {
        var stringToSign = "PUT\n" + /*HTTP Verb*/
                "\n" +    /*Content-Encoding*/
                "\n" +    /*Content-Language*/
                "\n" +    /*Content-Length*/
                "\n" +    /*Content-MD5*/
                "\n" +    /*Content-Type*/
                "\n" +    /*Date*/
                "\n" +    /*If-Modified-Since */
                "\n" +    /*If-Match*/
                "\n" +    /*If-None-Match*/
                "\n" +    /*If-Unmodified-Since*/
                "\n" +    /*Range*/
                "x-ms-date:" + dateInUTC + "\n" +
                "x-ms-version:" + apiVersion + "\n" +
                "/samplestorage/myqueue\n";
        
        var StorageAccountKey = "maVja38Ns6b4AXM+fMSOQApRuijoBJmXsQiqALYJqi6DQNbeVg3uu31S0ErZo0nLx6s74nrmk1zc5YBXGZ5jaA==";
        var signature = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(CryptoJS.enc.Utf8.parse(stringToSign), CryptoJS.enc.Base64.parse(StorageAccountKey)));
        console.log(signature);
        return signature;
    }

    When i test the query in the ARC rest client, i am getting the following error

    Failed to load resource: the server responded with a status of 403 (Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.)

    Can you please suggest me how to resolve this authentication error?




    • Edited by sk2014 Wednesday, May 18, 2016 6:40 AM
    Wednesday, May 18, 2016 6:19 AM

All replies