Я пытаюсь получить текущего пользователя от https://graph.microsoft.com/v1.0/me.
Я получаю действительный токен, однако запрос на https://graph.microsoft.com/v1.0/me дает мне a 404.
var token;
$(document).ready(function () {
requestToken();
});
function requestToken() {
$.ajax({
"async": true,
"crossDomain": true,
"url": "https://cors-anywhere.herokuapp.com/https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token",
"method": "POST",
"headers": {
"content-type": "application/x-www-form-urlencoded"
},
"data": {
"grant_type": "client_credentials",
"client_id ": "{client_id}",
"client_secret": "{client_secret}",
"scope ": "https://graph.microsoft.com/.default"
},
success: function (response) {
console.log(response);
token = response.access_token;
getUserInformation();
},
error: function (error) {
console.log(JSON.stringify(error));
}
})
}
function getUserInformation() {
$.ajax({
method: 'GET',
url: "https://graph.microsoft.com/v1.0/me",
headers: {
'Authorization': 'Bearer ' + token,
'Content-Type': 'application/json'
},
}).success(function(response) {
console.log(response);
}).error(function(error) {});
}
Кто-нибудь знает, в чем может быть проблема?
Спасибо.