【问题标题】:Azure Get User Delegation Failing on Expiry FormatAzure 在到期格式上获取用户委派失败
【发布时间】:2021-05-22 18:47:43
【问题描述】:

我正在尝试使用 REST API 为 Azure 存储获取 user delegation SAS token

我有一个帐户,该帐户具有存储帐户所需的角色,并且该帐户已成功通过身份验证并从登录端点返回了 Bearer 令牌。

当我请求用户授权密钥时,我不断收到以下错误:

<?xml version="1.0" encoding="utf-8"?>
<Error>
    <Code>InvalidXmlNodeValue</Code>
    <Message>The value for one of the XML nodes is not in the correct format.
RequestId:9b7a22e3-601e-0082-7bee-060981000000
Time:2021-02-19T18:38:48.1286734Z</Message>
    <XmlNodeName>Expiry</XmlNodeName>
    <XmlNodeValue>2021-02-19T19:30:00</XmlNodeValue>
</Error>

我提交的正文是从the Azure docs复制的:

<?xml version="1.0" encoding="utf-8"?>  
<KeyInfo>  
    <Start>2021-02-19T18:30:00</Start>
    <Expiry>2021-02-19T19:30:00</Expiry>
</KeyInfo>

知道我做错了什么或错过了什么导致失败吗?

在 Azure 上分配的角色是:

以及请求头:

Authorization: Bearer ...
x-ms-version: 2020-04-08
Content-Type: text/xml
User-Agent: PostmanRuntime/7.26.10
Accept: */*
Postman-Token: df276a57-747c-45dd-a849-15ac6ad7b45b
Host: ....blob.core.windows.net
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 147

【问题讨论】:

  • 您可以尝试像这样格式化到期时间:2021-02-19T19:30:00Z。参考docs.microsoft.com/en-us/rest/api/storageservices/…
  • 哦,这行得通!谢谢! @doris-lv
  • 我修改了我的答案,介意接受它供其他人参考吗?
  • 完成,再次感谢 :)

标签: azure azure-storage azure-sas


【解决方案1】:

问题可能是您的令牌生命周期太短,无法使其生效。我的建议是,将到期时间设置为比开始时间长 8 小时

到期时间的值最多可以是自到期日起 7 天 开始时间。

像这样格式化您的到期时间:

2021-02-19T19:30:00Z

参考:https://docs.microsoft.com/en-us/rest/api/storageservices/formatting-datetime-values

【讨论】:

  • 不幸的是,这不是问题 - 我尝试过在 12 小时、24 小时、48 小时后到期,它们都失败并显示相同的消息。
猜你喜欢
  • 2015-05-10
  • 2015-06-08
  • 2017-07-29
  • 1970-01-01
  • 2021-04-01
  • 1970-01-01
  • 2015-11-21
  • 2022-07-09
  • 2016-09-25
相关资源
最近更新 更多