Feb 18 2024 02:18 PM
Hi. I am trying to develop an outlook add-in and in my adding I want to forward and/or delete an email. for this I am using Microsoft exchange API like this
await axios.delete(`${OFFICE_URL}/me/messages/${mailId}`, {
headers: {
'Authorization': 'Bearer ' + accessToken,
'Content-Type': 'application/json',
'Accept': 'application/json',
}
});
but to be able to this I need to get an access token. From the Microsoft documentation (Microsoft getCallbackTokenAsync) I am trying to get my access token like this.
async function getAccessToken() {
return await new Promise((resolve, reject) => {
Office.context.mailbox.getCallbackTokenAsync(
{ isRest: true },
function (result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
resolve(result.value);
}
else {
reject(new Error(result))
}
})
});
}
This code is not working approximately for a week but before it was working and I was not getting an error. But this is not the case anymore. From developer tools, this is the request and payload I am sending.
Even though server responds with 200 (OK) it is not giving me my token. This is the response.
{
"Header": {
"ServerVersionInfo": {
"MajorVersion": 15,
"MinorVersion": 20,
"MajorBuildNumber": 7292,
"MinorBuildNumber": 29,
"Version": "V2018_01_08"
}
},
"Body": {
"ResponseMessages": {
"Items": [
{
"__type": "GetClientAccessTokenResponseMessage:#Exchange",
"Token": null,
"MessageText": "An internal server error occurred. The operation failed., One or more errors occurred.",
"ResponseCode": "ErrorInternalServerError",
"ResponseClass": "Error"
}
]
}
}
}
What I do not understand is that this was working fine just a week before and not just one time but it was working fine for more than a month.