尝试获取新的访问令牌时获取“ unauthorized_client”,为什么?

时间:2018-11-19 22:49:19

标签: azure azure-active-directory postman

我正在使用VS 2017开发API,正在使用Postman进行测试。我一直在关注此博客文章Getting started with Windows Azure AD Authentication using Postman。我终于得到它给我访问令牌和刷新令牌。在发布过程中大约四分之三的时间我遇到了这个问题:

资源:https://management.core.windows.net

必须放入Postman中(我使用的是Windows应用版本的Postman)。我不确定这是干什么的,所以我将其保留。最终,我获得了访问令牌和刷新令牌,但是当我何时要获取有关所有订阅的更多信息时,会出现错误,指出我已指定了有效资源。因此,我以为我需要做的就是重新开始,但要重新进行身份验证并从Azure中获取代码。我这样做了,并按照博客文章的指示将其放入Postman。但是,发布此POST会导致此错误:

"error": "unauthorized_client",
"error_description": "AADSTS70002: Error validating credentials. AADSTS65005: Invalid resource. The client has requested access to a resource which is not listed in the requested permissions in the client's application registration. Client app ID: d37abf69-42ce-4571-b146-f3422e73f041. Resource value from request: https://management.core.windows.net. Resource app ID: 797f4846-ba00-4fd7-ba43-dac1f8f63013. List of valid resources from app registration: 00000002-0000-0000-c000-000000000000.\r\nTrace ID: 9f028899-6d03-409e-8db4-4e9905000300\r\nCorrelation ID: ec253a1b-9fdc-495f-9310-6b40a42e5d93\r\nTimestamp: 2018-11-19 22:20:02Z",
"error_codes": [
70002,
65005
]

我不明白为什么也做错了什么。我已经按照教程的指示预先指定了资源,所以我做错了什么?

2 个答案:

答案 0 :(得分:1)

查看错误消息,看来您可能错过了为应用程序注册添加“ Windows Azure服务管理API”的相关权限。

步骤:

  1. 转到Azure门户> Azure AD>应用程序注册>您的应用程序(应用程序ID:d37abf69-42ce-4571-b146-f3422e73f041)

  2. 转到“设置”>“所需权限”>“添加”>选择“ Windows Azure Service Management API”

    enter image description here

  3. 在“委派权限”部分下选择相关权限。单击选择,然后单击“完成”。您应该在门户中收到一条通知,该通知已成功添加权限。您还应该在所需权限下看到Windows Azure服务管理API。

    enter image description here

完成这些步骤后,请按照您在Postman步骤中提到的博客文章继续操作,以再次获取访问令牌。

答案 1 :(得分:0)

当我尝试设置Postman时,我发现自己处在相同的情况。它不像大多数博客看起来的那么复杂。我创建了一个教程,试图简化该过程。

http://hazelnest.com/blog/blog/2018/11/17/azure-postman-configuration/

https://youtu.be/2bfgeBKRxl4

希望这会有所帮助。

相关问题