azure - 无法获取自定义 AD 应用程序的访问令牌
问题描述
尝试使用 获取自定义 AD 应用程序的访问令牌时az account get-access-token --resource '<APP ID Uri>'
,我收到以下错误:
AADSTS65001: The user or administrator has not consented to use the application with ID '04b07795-8ddb-461a-bbee-02f9e1bf7b46' named 'Microsoft Azure CLI'. Send an interactive authorization request for this user and resource.
04b07795-8ddb-461a-bbee-02f9e1bf7b46
不是我的应用程序 ID,并且我的应用程序已获得管理员同意。我尝试将此 id 放在交互式登录请求中,而行为没有改变。
get-access-token
当资源是一个定义的 MS 端点时工作正常,例如https://database.windows.net
或https://vault.azure.net/
我的目标是让带有托管服务标识的 Azure 应用服务使用短暂的 AD 不记名令牌相互进行身份验证。每个服务都有一个对应于 AD 应用程序的已配置受众。
解决方案
从本地 CLI运行az account get-access-token --resource '<APP ID Uri>'
,您尝试'<APP ID Uri>'
使用 Azure CLI 获取令牌,其客户端 ID 正好是04b07795-8ddb-461a-bbee-02f9e1bf7b46
.
要处理此问题,您可以转到: Azure Active Directory → 应用注册 → {您的应用} → 公开 API → 添加客户端应用程序:
身份证:
04b07795-8ddb-461a-bbee-02f9e1bf7b46
授权范围:检查
'<APP ID Uri>'
为确保您拥有正确的 ID,您可以运行将az account get-access-token
令牌粘贴到jwt.io并找到"appid"
.
推荐阅读
- javascript - 在 Vue 之外使用 Buefy 组件
- java - JTable中的JComboBox不保存选择
- python - 大熊猫中的 df.iloc 函数不起作用
- php - 使用 cookie 时出现内部服务器错误 500
- android - Firestore 文档对象 (documentSnapshot) 到带有嵌套映射的 POJO
- node.js - Heroku 给了我一个 503 我不知道为什么
- python-3.6 - 拦截python脚本完成
- git - 我把一个目录变成了一个 git repo。如何撤消它?
- html - 滚动条不在可见区域(宽度超过 100%)
- sql - 同一查询中求和时的不同条件