Outlook Mac App Token Mismatch

I am implementing an add-in for Outlook, the add-in receives the attachment and sends it to my server for processing. It works flawlessly at https://outlook.office.com , but does not start Outlook 2016 for Mac.

Here is the API I'm trying to access:

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 ); } } 

Using Outlook 2016 for Mac, I get 401 from the above API.

Also, the auth_token that I get from calling getCallbackTokenAsync in Outlook 2016 for Mac is different from the one I get in the browser:

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

The values ​​in my manifest are:

 <Set Name="MailBox" MinVersion="1.3"/> <Permissions>ReadWriteMailbox</Permissions> 

Can someone point out what I'm doing wrong here?

UPDATE According to Jason's suggestion, I checked the token that I received on jwt.io The token options vary in browser and in mac application.

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

How do I get outlook_mac_app to return a v2 token?

+5
source share
1 answer

I can not comment, so I am posting this as an answer.

I clicked 403 for attachments in Outlook for Mac 2016, not sure if they are connected, but you can take a look at it here https://github.com/OfficeDev/outlook-add-in-command-demo/issues/30

+1
source

Source: https://habr.com/ru/post/1275105/


All Articles