首页 文章

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

提问于
浏览
5

我正在为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
        );
    }
}

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

另外,我在Outlook 2016 for Mac上调用 getCallbackTokenAsync 获得的 auth_token 与我在浏览器中调用的不同:

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>

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

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

On the Browser: "ver": "Exchange.Callback.V2" On the Mac App: "ver": "Exchange.Callback.V1"

How do I get the outlook_mac_app to return v2 of the token?

1 回答

相关问题