Is there a way to utilize adal.js
within AngularJS to obtain a bearer token for the audience https://management.azure.com
through JavaScript?
I have created a client application in Azure AD and configured its permissions to allow access to the "Windows Azure Service Management API". Below is the code snippet from my AngularJS application:
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
);
When using the token received from this adalService in POSTMAN to access
https://management.azure.com/subscriptions?api-version=2014-04-01
, I encounter the following error message:
The access token has been obtained from the wrong audience or resource '<some id>'.
It must precisely match (including forward slash) with one of the allowed audiences 'https://management.core.windows.net/', 'https://management.azure.com/'.