【发布时间】:2020-09-20 20:09:20
【问题描述】:
我对 Outlook 插件开发非常陌生。对于我的插件,我需要从当前 Outlook 帐户中获取所有联系人。我尝试使用以下代码:
Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function (result) {
if (result.status === "succeeded") {
var accessToken = result.value;
console.log("access token", accessToken);
getCurrentItem(accessToken);
} else {
// Handle the error.
}
});
function getCurrentItem(accessToken) {
var getcontacts = Office.context.mailbox.restUrl +
'/v2.0/me/contacts';
console.log(getcontacts);
$.ajax({
url: getcontacts,
dataType: 'json',
headers: { 'Authorization': 'Bearer ' + accessToken }
}).done(function (item) {
console.log(item);
}).fail(function (error) {
// Handle error.
});
}
当我在 Outlook 插件中使用此 js 文件并对其进行安慰时,以 403 禁止错误结束。这个怎么用?我的代码中是否存在错误?
提前致谢!
【问题讨论】:
标签: outlook office365 outlook-addin outlook-web-addins outlook-restapi