我对微软分散的文档有点困惑。Keyvault身份验证(REST API)
我已经创建了一个应用程序(https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal),这意味着我现在有:
- 应用ID
- 重点
- 目录编号
我已经到Azure中KeyVault门户网站和我已授予应用程序的权限。
出于测试目的,我试图通过CURL运行测试。我使用该算法的基础是下面的Microsoft网页(https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-service-to-service#request-an-access-token和https://docs.microsoft.com/en-us/rest/api/#create-the-request)
所以,我做的第一件事就是通过下面的调用获取令牌:
curl -d "grant_type=client_credentials&client_id=<removed_for_security>&client_secret=<removed_for_security>" https://login.microsoftonline.com/<removed_for_security>/oauth2/token
这将返回一个令牌。
然后我(尝试)使用该令牌如下:
curl -H "Authorization: Bearer <removed_for_security>” -vv https://<removed_for_security>.vault.azure.net/secrets/<removed_for_security>/<removed_for_security>
我没有得到任何内容,则只需“HTTP/1.1 401未经授权”
是。我忘了API版本。 –
很奇怪,当我删除API版本时,它特意告诉我,我忘了指定API版本......很高兴知道它的工作原理@LittleCode – 4c74356b41