I'm working on AngularJS application which authenticates the user with Azure AD using adalJS. I'm trying to access the logged in user's details from AD using the Graph REST API. But I get a 401 (Unauthorized: Missing or malformed access token) error. Below is my code.
adalAuthenticationService.acquireToken("https://graph.windows.net/").then(function (token) {
console.log(token);
var req = {
method: 'GET',
url: 'https://graph.windows.net/me?api-version=1.5',
headers: {
'Authorization': 'Bearer ' + token
}
};
$http(req).then(function (response) {
console.log(response);
}, function (response) {
console.log(response);
});
});
I have created the application in AAD and configured the permissions to the Azure AD as well. Can anyone elaborate on this error? Is the token that I pass not the access token?