我在Azure App Service上有一个需要Azure Active Directory身份验证的Web应用程序.我可以使用OAuth 2.0流程进行服务到服务通信或托管服务标识(MSI),从其他应用程序中连接受保护应用程序的访问令牌.
对于MSI,Microsoft提供了一个库Microsoft.Azure.Services.AppAuthentication,用于身份验证,该库还支持使用该azure-cli工具的凭据.
但是,该库目前处于预览状态,它不能在我的系统上运行,但我设法在github上找到它的源代码.
该相关部分似乎调用
$ az account get-access-token <resource>
但是,当我尝试使用我尝试访问的应用程序的资源名称时,我收到以下错误:
Get Token request returned http error: 400 and server response: {"error":"invalid_grant","error_description":"AADSTS65001: The user or administrator has not consented to use the application with ID <application id> named <application name>.
对于资源名称,我尝试了App ID URI和Client ID.
有没有人设法azure-cli在类似的场景中使用获取访问令牌?