Outlook Mac App身份验证令牌不匹配

Emp*_*Cup 5 javascript office-addins office-js outlook-web-addins outlook-for-mac

我正在为Outlook实现一个加载项,加载项获取一个附件并将其发送到我的服务器进行处理.它在https://outlook.office.com上运行完美,但无法运行Outlook 2016 for Mac.

这是我试图访问的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
        );
    }
}
Run Code Online (Sandbox Code Playgroud)

使用Outlook 2016 for Mac,我401从上面的API中获得了一个.

此外,auth_token我从调用getCallbackTokenAsyncOutlook 2016 for Mac获得的不同于我在浏览器中调用的内容:

Office.context.mailbox.getCallbackTokenAsync({isRest: true}, function (result) {
    if (result.status === "succeeded") {
        //save result.value
    } 
    else {
        //error condition
    }
});
Run Code Online (Sandbox Code Playgroud)

我的清单中的值是:

<Set Name="MailBox" MinVersion="1.3"/>
<Permissions>ReadWriteMailbox</Permissions>
Run Code Online (Sandbox Code Playgroud)

谁能指出我在这里做错了什么?

更新 根据Jason的建议,我检查了我在jwt.io上收到的令牌.令牌 的版本在浏览器和mac应用程序上有所不同.

On the Browser: "ver": "Exchange.Callback.V2" On the Mac App: "ver": "Exchange.Callback.V1" 
Run Code Online (Sandbox Code Playgroud)

如何让outlook_mac_app返回令牌的v2?

小智 1

我无法发表评论,因此将其发布为答案。

我在 Outlook for Mac 2016 中遇到附件错误 403,不确定它们是否相关,但您可以在此处查看https://github.com/OfficeDev/outlook-add-in-command-demo/issues/ 30