gpt4 book ai didi

使用 Azure Active Directory Oauth 进行 Azure 服务管理 API 身份验证

转载 作者:行者123 更新时间:2023-12-01 09:03:20 29 4
gpt4 key购买 nike

我想通过curl 使用Azure AD 向Azure 服务管理API 进行身份验证。

set up an application在我的默认目录中。在这个免费试用订阅中,这是我拥有的唯一目录。

当我定位 oauth token 端点时,我收到一个 JWT。

curl --data "grant_type=client_credentials&client_id=<my_client_id>&client_secret=<my_encoded_secret>&resource=https%3A%2F%2Fmanagement.core.windows.net" https://login.windows.net/<my_tenant_id>/oauth2/token

但是当我使用该 token 列出我的订阅详细信息时,我收到错误:

curl -H "x-ms-version: 2014-06-01" \
-H "Authorization: Bearer <my_token>" \
https://management.core.windows.net/<my_subscription_id>/

<Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Code>ForbiddenError</Code>
<Message>The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription.</Message>
</Error>

我已将应用程序的服务管理 API 的权限授予为“委派权限”,因为“应用程序权限”不可用。

enter image description here

我错过了什么?

最佳答案

由于服务管理 API 的应用程序权限:0 设置,这是不可能的。 client_credentials 授权类型使用来自应用程序的凭据(client_id 和 client_secret),并且由于应用程序没有此 API 的权限,因此调用失败。

由于服务管理 API 不允许任何类型的应用程序权限,因此我们必须使用 authorization_code grant type或其他一些获取用户 token 的方法。

关于使用 Azure Active Directory Oauth 进行 Azure 服务管理 API 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26003820/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com