我正在为Outlook实现一个外接程序,外接程序获取一个附件并将其发送到我的服务器进行处理。它在https://outlook.office.com上运行得完美无缺,但未能为Mac运行Outlook2016。
下面是我要访问的API:
var getMessageUrl =Office.context.mailbox.restUrl + '/v2.0/me/messages/' +
{messageID} + "/attachments/" + {attachmentID};
var attachmentID = Office.context.mailbox.item.attachments[0].id;
var messageID = getItemRestId();
$.ajax({
url: getMessageUrl,
dataType: 'json',
headers: {
'Authorization': 'Bearer ' + outlookToken
}
}).done(function 1(response) {
//upload the blob to my server
}).fail(function (error) {
//call authorise to get a new token
});
function getItemRestId() {
if (Office.context.mailbox.diagnostics.hostName === 'OutlookIOS') {
// itemId is already REST-formatted
return Office.context.mailbox.item.itemId;
} else {
// Convert to an item ID for API v2.0
return Office.context.mailbox.convertToRestId(
Office.context.mailbox.item.itemId,
Office.MailboxEnums.RestVersion.v2_0
);
}
}使用Outlook2016forMac,我从上面的API中得到一个401。
此外,我在Outlook 2016上为Mac调用的auth_token与在浏览器中获得的getCallbackTokenAsync不同:
Office.context.mailbox.getCallbackTokenAsync({isRest: true}, function (result) {
if (result.status === "succeeded") {
//save result.value
}
else {
//error condition
}
});我的清单中的值是:
<Set Name="MailBox" MinVersion="1.3"/>
<Permissions>ReadWriteMailbox</Permissions>有人能指出我在这里做错了什么吗?
根据的建议,我检查了在jwt.io上收到的令牌--在浏览器和mac应用程序中,令牌的版本不同。
On the Browser: "ver": "Exchange.Callback.V2" On the Mac App: "ver": "Exchange.Callback.V1" 如何使outlook_mac_app返回令牌的v2?
发布于 2018-02-01 18:52:38
我不能对此发表评论,所以将此作为回答。
我在Mac2016OutlookforMac2016中访问了403个附件,不确定它们是否相关,但是您可以在这里查看一下https://github.com/OfficeDev/outlook-add-in-command-demo/issues/30
https://stackoverflow.com/questions/48561863
复制相似问题