i'm currently developing an Office Outlook App. I'm trying to get the messages (specially the Attachments of messages) from the Exchange Server. I'm using the Outlook Desktop Application.
I already got the bearer authentication token and i'm trying using the Office REST-API to get the messages, but there is a strange error if i send the GET request to the server.
Error: "The api you are trying to access does not support item scoped OAuth."
Here is my JavaScript-Code:
Office.context.mailbox.getCallbackTokenAsync(function (asyncResult) {
if (asyncResult.status === "succeeded") {
var authToken = asyncResult.value;
var attUrl = 'https://outlook.office.com/api/v2.0/me/mailfolders/inbox/messages/';
$.ajax({
method: "GET",
url: attUrl,
beforeSend: function (request) {
request.setRequestHeader("Accept", "text/*, application/xml, application/json; odata.metadata=none");
request.setRequestHeader("Authorization", "Bearer " + authToken);
request.setRequestHeader("X-AnchorMailbox", "[email protected]");
},
success: function (responseData) {
console.log("success", responseData);
},
error: function (errData) {
console.log("err", errData);
}
});
}
});
I'm scanning the outgoing traffic and there seems everything ok:
GET outlook.office.com/api/v2.0/me/mailfolders/inbox/messages/ HTTP/1.1
Authorization: Bearer TokenIsCorrect
Accept: text/*, application/xml, application/json; odata.metadata=none
X-AnchorMailbox: [email protected]
Referer: localhost:44300/AddInRead/App/Index/Index.html
Accept-Language: de-DE
Origin: localhost:44300
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Host: outlook.office.com
DNT: 1
Connection: Keep-Alive
Cache-Control: no-cache
.................
I refered to: Outlook Mail REST-API Reference
and the samples on Outlook Dev Center OAuth Sandbox
I think i searched the hole internet, but couldn't find anything to fix this problem.
Hopefully someone can give me the right hint.
BTW: had to remove some links cause of no reputation of my account :/
Thanks !