https://graph.microsoft.com/v1.0/me正在给出404



我正在尝试从https://graph.microsoft.com/v1.0/me.

然而,我得到了一个有效的令牌,请求https://graph.microsoft.com/v1.0/me给我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) {});
}

有人知道问题出在哪里吗?

谢谢。

我得到了详细的回复:"错误":{"code":"Request_ResourceNotFound","message":"资源"不存在,或者其查询的引用属性对象之一不存在。","innerError":{"请求id":","日期":"2020-04-17T09:33:43"}}}

来自https://graph.microsoft.com/v1.0/me

我得到了:

{
"error": {
"code": "InvalidAuthenticationToken",
"message": "Access token is empty.",
"innerError": {
"date": "2020-10-20T11:39:50",
"request-id": "becb1443-91e3-42d9-9c77-b9808aaf2cf7",
"client-request-id": "becb1443-91e3-42d9-9c77-b9808aaf2cf7"
}
}
}

https://graph.microsoft.com/.default

{
"error": {
"code": "BadRequest",
"message": "Invalid version.",
"innerError": {
"date": "2020-10-20T11:41:04",
"request-id": "3fdd24bd-7c96-4ff2-9e18-fc042673ecd2",
"client-request-id": "3fdd24bd-7c96-4ff2-9e18-fc042673ecd2"
}
}
}

最新更新