【发布时间】:2015-07-09 06:05:18
【问题描述】:
如何在 AngularJS 中使用 adal.js 从我的 javascript 代码中为观众 https://management.azure.com 获取不记名令牌?
我在 AD 中创建了一个客户端应用程序并设置其权限以允许它访问“Windows Azure 服务管理 API”。我的angularjs代码如下:
adalService.init(
{
instance: "https://login.windows.net/",
tenant: "<something>.onmicrosoft.com",
clientId: "<some id>",
cacheLocation: 'localStorage',
redirectUri: 'http://localhost:63691/index.html#/configure',
endpoints: {
/* 'target endpoint to be called': 'target endpoint's resource ID' */
'https://management.azure.com/subscriptions?api-version=2014-04-01': 'https://management.azure.com/'
}
},
$httpProvider
);
如果我在 POSTMAN 中使用此 adalService 收到的令牌调用 https://management.azure.com/subscriptions?api-version=2014-04-01,则会收到以下错误:
The access token has been obtained from wrong audience or resource '<some id>'.
It should exactly match (including forward slash) with one of the allowed audiences 'https://management.core.windows.net/','https://management.azure.com/'.
【问题讨论】:
标签: javascript angularjs azure azure-active-directory adal.js