【发布时间】:2021-07-29 21:35:05
【问题描述】:
使用 Azure Storage API 访问文件服务时,我们收到以下错误。
<?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:5a7f5ef2-a01a-0023-134e-436c77000000 Time:2021-05-07T14:36:32.7067133Z</Message>
<AuthenticationErrorDetail>Unversioned authenticated access is not allowed.</AuthenticationErrorDetail>
</Error>
我们遵循了文档并相信我们拥有所有正确的标题,但显然缺少一些东西。
我们正在编码的签名字符串:
GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Fri, 07 May 2021 15:29:49 GMT\nx-ms-version:2020-04-08\n/*our_azure_resource*\ncomp:metadata
使用我们用来进行编码的 CryptoJS 的代码
let signature = CryptoJS.HmacSHA256(CryptoJS.enc.Utf8.parse(stringToSign).toString(), this.key)
.toString(CryptoJS.enc.Base64);
授权标头的值:
SharedKey storageaccountname:decodedstring
【问题讨论】:
-
可以分享请求头吗?
-
嗨@GauravMantri,请求标头将如下所示,因为我们在签名
Authorization: SharedKey storageaccountname:decodedstring中提供x-ms-date的值 -
@bengrah 请在您的 HTTP 请求标头中添加
x-ms-version:2020-04-08。
标签: azure azure-storage