我需要幫助構建授權標頭來放置塊blob。在Postman中使用Blob服務API傳遞blob - 授權標頭
PUT \ n \ n \ n11 \ n \ n \ n \ n \ n \ n \ n \ n \ n \ nx-ms-blob-type:BlockBlob \ nx-ms-date:2017年2月25日:20:13 GMT \ nx-ms-version:2015-02-21 \ n/myaccountname/mycontainername/blob.txt \ n
我把這個,UTF 8編碼它。然後,我在我的Azure帳戶中使用我的訪問密鑰,並將HMAC sha256 UTF 8編碼的字符串與密鑰關聯起來。然後我用base64輸出。我們來調用這個輸出字符串。
我的授權頭看起來是這樣的:SharedKey myaccountname:輸出字符串
這是行不通的。
郵差中的郵件頭也有x-ms-blob-type,x-ms-date,x-ms-version,Content-Length和Authorization。現在的身體說,你好世界。
任何人都可以幫助我在郵遞員這個成功的要求嗎?
<?xml version="1.0" encoding="utf-8"?>
<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:cdeb9a5e-0001-0029-5fb5-8f7995000000
Time:2017-02-25T22:22:32.0300016Z</Message>
<AuthenticationErrorDetail>The MAC signature found in the HTTP request 'jiJtirohvi1syXulqkPKESnmQEJI4GpDU5JBn7BM/xY=' is not the same as any computed signature. Server used following string to sign: 'PUT
11
text/plain;charset=UTF-8
x-ms-date:Sat, 25 Feb 2017 22:20:13 GMT
x-ms-version:2015-02-21
/myaccountname/mycontainername/blob.txt'.</AuthenticationErrorDetail>
</Error>
編輯:
首先,我要感謝你,大家誰迴應。我真的很感激它。我有最後一個問題,然後我想我會被設置!我沒有使用該代碼 - 我手動完成這一切。如果我有我的密鑰:X2iiy6v47j1jZZH5555555555zzQRrIAdxxVs55555555555av8uBungcBMotmS7tDqas14gU5O/w ==稍微改變了一下匿名 - 我解碼它:使用在線base64解碼器。然後,當我有我的字符串,現在看起來像這樣:PUT \ n \ n \ n11 \ n \ ntext \ plain; charset = UTF-8 \ n \ n \ n \ n \ n \ n \ n \ nx-ms-blob -type:BlockBlob \ nx-ms-date:Mon,27 Feb 2017 21:53:13 GMT \ nx-ms-version:2015-02-21 \ n/myaccount/mycontainer/blob.txt \ n所以我運行這個在https://mothereff.in/utf-8然後在HMAC中用我的解碼密鑰:https://www.liavaag.org/English/SHA-Generator/HMAC/ - 在末尾使用sha256和base64。那是我如何得到正確的字符串放到這裏:SharedKey我的帳戶:
由於「\ n」字符,使用您提到生成的代碼與簽名不匹配的工具。我寫了一個[在線工具](https://onlineencrypt.herokuapp.com/)來生成簽名。我也更新了答案。 –