Azure REST API中的Authorization中的头标到底该怎么写

Authorization中的头标到底该怎么写
官方给出的格式如下

Authorization="[SharedKey|SharedKeyLite] <AccountName>:<Signature>" 

主要是部分,官方给出的生成方法如下

Signature=Base64(HMAC-SHA256(UTF8(StringToSign)))

如此,在php中,生成HMAC-SHA256的函数是(参考了PHP: hash_hmac -Manual)

hash_hmac ( string $algo , string $data , string $key [, bool $raw_output = false ] )

我是这么使用的

hash_hmac('sha256',$str,'');

那么问题来了,这种函数需要的第三个参数是一个key,不然无法生成结果。这里的key到底要填啥??

尝试着把key字段换成了访问密钥,用php生成的$Out就是需要的Signature,大神们看看这样行不,这样生成的Signature还是无法使用。

 <?php
    $preString = "GET\n\n\n\n\n\n\n\n\n\n\n\n";
    $headString = "x-ms-date:Sun, 22 May 2016 16:50:38 GMT\nx-ms-version:2014-02-14\n";
    $resString = "/uroxoscna/main\ncomp:list\nrestype:container";
    $str = utf8_encode($preString.$headString.$resString);
    $Out = base64_encode(hash_hmac('sha256',$str,'******AL6hV87zEwyflurXXOrjKmFALuNKCODPMi4SlJfaaPH39p9LRZM95NoE46TWXUFmeDhJn8Tpe3Hnas/Q=='));
    echo $Out;

GET测试

Hi,

请查看我在MSDN中的回复:https://social.msdn.microsoft.com/Forums/zh-CN/4e52d300-4dde-498c-a977-4a6ca9601fcb/azure-rest-apiauthorization?forum=windowsazurezhchs

您可以选择在CSDN或者MSDN继续跟帖,如果您有关于Azure的新问题也欢迎来CSDN论坛提问。

Best Regards,
Jambor