生成仅应用程序令牌失败,错误代码为 AADSTS500011

问题描述 投票:0回答:1

我正在尝试使用创建仅应用程序令牌。

POST https://login.microsoftonline.com/%7B%7BtenantId%7D}/oauth2/token

参数“client_id”,client_secret,范围,grant_type =“client_credentials”,资源

请告诉我它如何/什么验证“资源”参数?

当我使用时

问题

为什么我可以获取 Azure 中继 uri 的令牌,而无需在租户中配置此资源。但为什么我的 Azure 应用程序的资源 uri 无法生成令牌。

我不想在客户租户中配置我的资源。

azure-active-directory entra
1个回答
0
投票

我创建了一个 Azure Web 应用程序并将 Microsoft 添加为身份提供商

enter image description here

我通过邮递员将 resource 传递为

https://MyApp.azurewebsites.net
生成访问令牌,并得到相同的错误:

https://login.microsoftonline.com/TenantID/oauth2/token

client_id:ClientID
client_secret:ClientSecret
grant_type:client_credentials
resource:https://rukwebapp33.azurewebsites.net

enter image description here

AADSTS500011:在名为 Contoso 的租户中找不到名为 https://rukwebapp33.azurewebsites.net 的资源主体。如果应用程序尚未由租户管理员安装或未得到租户中任何用户的同意,则可能会发生这种情况。您可能已将身份验证请求发送给了错误的租户。

如果您传递无效的资源/范围来生成访问令牌,通常会发生此错误。

要解决该错误,您需要将资源作为 Microsoft Entra 应用程序的应用程序 ID/ClientID 传递,该应用程序被添加为 Web 应用程序的身份提供程序。

enter image description here

您还可以从 Microsoft Entra 应用程序的概述页面获取 应用程序 ID:

enter image description here

现在,当我传递

资源作为应用程序的应用程序ID时,我成功获得了访问令牌:

https://login.microsoftonline.com/TenantID/oauth2/token client_id:ClientID client_secret:ClientSecret grant_type:client_credentials resource:ClientID

enter image description here

通过使用上述访问令牌,

我能够成功调用Web应用程序:

GET https://rukwebapp33.azurewebsites.net

enter image description here

参考资料:

javascript - 错误:AADSTS500011:在租户中找不到名为“URL”的资源主体 - Stack Overflow,作者:juunas

如何使用 Azure AD 身份验证保护 Azure 应用服务,作者:Carl de Souza

© www.soinside.com 2019 - 2024. All rights reserved.