我希望获得无需用户交互的访问令牌,以便将对REST API调用自动化到Azure服务(计算,网络等)。 In the documentation,列出了几种认证方案。最符合我的用例的是“守护进程或服务器应用程序到Web API”。如何在没有用户交互的情况下对Azure Active Directory进行身份验证?
我跟着instructions请求访问令牌:首先,我在Azure Active Directory中注册了一个App。然后我创建了一个与应用程序ID(client_id参数)关联的密钥(client_secret参数)。我还获得了App ID URI(资源参数)。我使用所有这些参数来创建一个POST请求到我的Azure AD的/ token端点。但是,我收到以下错误消息:
{
"code":"InvalidAuthenticationTokenAudience",
"message":"The access token has been obtained from wrong audience or resource 'https://solutionsmosaixsoft.onmicrosoft.com/<APP_ID_URI>'. It should exactly match (including forward slash) with one of the allowed audiences 'https://management.core.windows.net/','https://management.azure.com/'."
}
我在做什么错?我是否将资源参数设置为错误的值?
在[此页](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-service-to-service#request-an-access-token),它表示资源参数为: '输入接收Web服务的App ID URI。要查找App ID URI,请在Azure管理门户中单击Active Directory,单击目录,单击该应用程序,然后单击配置。“ 此信息是否错误? –
@GlebBillig,我编辑了答案来解释你的问题,请检查一下。 –