【发布时间】:2016-05-31 22:51:08
【问题描述】:
我正在创建一个程序来删除 CDN 缓存。所以我按照文档说的做了,我仍然得到这个:
{ “错误”: { "code": "AuthenticationFailedInvalidHeader", "message": "身份验证失败。'Authorization' 标头以无效格式提供。" } }
所以它基本上说身份验证令牌本身格式错误(没有错误或过期)。即使我按照文档的建议做了。
我的请求-响应流程如下所示(我混淆了真实数据):
REQUEST
POST /subscriptions/29bdq1a7-348b-48fe-b9e6-b90c432892ff/resourceGroups/cdn-4/providers/Microsoft.Cdn/Profiles/CDN-3-Premium/endpoints/custom-endpoint.azureedge.net/purge?api-version=2015-06-01 HTTP/1.1
Content-Length: 90
User-Agent: GuzzleHttp/6.1.1 curl/7.35.0 PHP/7.0.2-2+deb.sury.org~trusty+1
Host: management.azure.com
Authorization: SharedAccessSignature uid=56c6d48a66904d02ce030003&ex=2017-02-19T11:41:00.0000000Z&sn=9wBsmFuP1ps01rt8nVlvsiAIdJMOqNsmGaiXUlfT35RxOvWAjHHcSIQdJA8v9wGvX4bJgX5fu1QyqVG6y9iQ6Q==
Content-Type: application/json
{
"ContentPaths": [
"/uploads/static/ads_en.json",
"/pic2.jpg"
]
}
RESPONSE
HTTP/1.1 401 Unauthorized
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
WWW-Authenticate: Bearer authorization_uri="https://login.windows.net/c87x6f33-af21-4461-a5b1-29647d8e9281", error="invalid_token", error_description="The authentication scheme of SharedAccessSignature is not supported."
x-ms-failure-cause: gateway
x-ms-request-id: 3514027b-e731-411c-b8es-cdf77d636284
x-ms-correlation-request-id: 3514137b-e731-411c-b8ee-cdf77d636284
x-ms-routing-request-id: WESTEUROPE:20160219T110919Z:3514037b-e731-411c-b7ee-cdf77d636184
Strict-Transport-Security: max-age=31536000; includeSubDomains
Date: Fri, 19 Feb 2016 11:09:19 GMT
Connection: close
Content-Length: 150
{"error":{"code":"AuthenticationFailedInvalidHeader","message":"Authentication failed. The 'Authorization' header is provided in an invalid format."}}\
你能提出解决方法吗?
【问题讨论】:
-
根据什么文档? REST api 是否支持 SharedAccessSignatures?
-
第一个链接是关于 Azure API 管理(azure.microsoft.com/en-us/documentation/articles/…),这是一个不同的产品。它不是 Azure Rest API。有关更多信息,请参阅此链接:msdn.microsoft.com/en-us/library/azure/ee460782.aspx
-
到目前为止,我了解到我必须遵循 AD 授权流程:blogs.msdn.com/b/gianlucb/archive/2016/01/18/… 和 msdn.microsoft.com/en-us/library/azure/ee460782.aspx(第一部分)
-
没错,您必须使用来自 AAD 的不记名令牌。 msdn.microsoft.com/en-us/library/azure/dn790557.aspx