Outlook Addin - getCallbackTokenAsync fails- code 9017 - outlook

Our company is using the Office js Rest API (via Outlook 2016) to retrieve a token for given user, and it just started failing. Investigation points to:
Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function (result)
returns error code 9017:
{"value":null,"status":"failed","error":{"name": "AccessRestricted", "message": "Internal protocol error: '-2147467259'."}}
We have ensured this request is made after
Office.initialize = function (reason) {...
has completed its operations (also this just started breaking for us this week/today).
Any guidance is greatly appreciated.. since this is a 'simple' call w/o any arguments to change the call signature, we're not really sure how to proceed.
Environment info:
Application: Outlook 2019 V1902 (Build 11328.20438)
Account: https://outlook.office.com/owa/{myUser}
Office.js API URL: "https://outlook.office.com/api/v2.0/me/"

It appears the issue was due to an API error when calling getCallbackTokenAsync - operation returned to normal this morning and we are no longer able to replicate the error.
We're going to chuck this up to an oops at MS. Any additional information regarding this error is much appreciated.
UPDATE: scratch that, error is back, what's going on MS?

Related

"Subscription validation request failed. Notification endpoint must respond with 200 OK to validation request"

I finished this tutorial https://learn.microsoft.com/en-us/graph/tutorials/azure-functions?tutorial-step=5 everything worked fine until i published my azure Functions in my Azure App.
When i try to make the subscription i get this error "Subscription validation request failed. Notification endpoint must respond with 200 OK to validation request". When i test with ngrok i can create the subscription with no problems but when i replace NgrokURL value for my Azure function Url, not. Is that the right way to create the susbcription? Also i tried to create the subscription in Graph Explorer but i still get this message.
As the same question raised in MSFT Docs Q&A Forum and thanks to the Shwetachoudhary provided the solution that helps other community members:
In the following below code,
content type must be text/plain.
body must include the validation token.
CodeSamples
asp .net mvc sample - Specifically look at the NotificationController.cs file
In the method
[HttpPost]
public async Task<ActionResult> Listen()
{
if (Request.QueryString["validationToken"] != null)
{
var token = Request.QueryString["validationToken"];
return Content(token, "plain/text");
}
'notificationUrl' must be able to respond to the request for validation. Make sure the validation token returns as plain/text as well. Refer to the Notification endpoint validation document provided by Microsoft.
Try isolating the code and calling the same API with Postman or Graph Explorer and see the results.

Getting 'name_taken' error when creating new Slack channel via API, despite no channel with that name

I'm receiving a name_taken error when creating a slack channel via the API using the conversations.create endpoint. My code was working fine up until a couple days ago, but now I get that error no matter what slack workspace I am in, even a brand new one that has no channels other than default ones. The Slack API docs say that the error means "A channel cannot be created with the given name," so it likely isn't because there is already a channel with that name, but I have no idea what else would cause this issue. I also tried testing it in Postman, and I get the same error.
However, if I make the channel name I want to create gibberish, it works. This leads me to believe that it has more to do with my slack configuration than my API request, but I am at a loss as to how. I would really appreciate any help someone could provide. Below is the code that makes the API call, as well as the response I get. Thanks in advance.
Request:
const channelName = 'moxified'
const createdChannel = JSON.parse(await request.post(`https://slack.com/api/conversations.create`, {
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: `token=${slackTokenResponse.authed_user.access_token}&name=${channelName}`, //name may change
}));
Response:
{ok: false, error: 'name_taken'}
After reaching out to a Slack developer, they explained that the interference was coming from the fact that my bot's name was also 'moxified'. To quote them, "Channel namespaces can be taken up by user groups as well as a name of a bot." I still don't get why it was working for so long without issue, but I hope this helps someone else one day :)

MailboxNotEnabledForRESTAPI - Microsoft Graph API integration with HMA Enabled on-premise server

We had integrated our application with Microsoft Graph API enabling user to access their outlook through our application.
The integration works fine with office365 users but having intermittent issues with users in on-premise server.
Initially after enabling HMA in on-premise server the integration started working, but for past two weeks we are facing issue with the integration and receiving error message as below.
HTTP error: 404
Error code: MailboxNotEnabledForRESTAPI or MailboxNotSupportedForRESTAPI
Error message: "REST API is not yet supported for this mailbox."
But we had not made any recent changes to server or Graph API access.
Surprisingly, it started to working today as this was sporadic we need assistance in understanding the issue. Any help is greatly appreciated.
Update: We started seeing the error again early today and we have captured the following log information.
{
"error": {
"code": "ResourceNotFound",
"message": "Resource could not be discovered.",
"innerError": {
"date": "2020-10-30T08:03:20",
"request-id": "c1f461d7-0757-4a54-a727-58cb0da7fe5d",
"client-request-id": "c1f461d7-0757-4a54-a727-58cb0da7fe5d"
}
}
}
This post is not an answer :-(, but should provide more details because we are running into the same issue.
To isolate the problem, we only using postman. We are not able to create a "working token" with postman. We tried like every possible O-Auth flow :-). When we use the token generated by "Graph Playground" requests are working.
What means "working token":
Request to: https://graph.microsoft.com/v1.0/me -> GP works | PM works
Request to: https://graph.microsoft.com/v1.0/me/calendar -> GP works | PM don't work
Request to: https://graph.microsoft.com/v1.0/me/contacts > GP works | PM don't work
.....
(GP = Graph Playground // PM = Postman)
Token
On the left side we see the token created via postman. On the right side we see the token from Graph online. I can't find an important difference, you can ? :-)

Google HomeGraph API: PERMISSION_DENIED error

I am making a smart home app using Actions On Google. I currently have a Firebase cloud function that calls the HomeGraph API with a Request Sync request.
Here's the contents of the function:
const {smarthome} = require('actions-on-google');
const app = smarthome({
key: "(My Key)"
});
//Assume UID is the id of the user that we are requesting a sync for
app.requestSync(uid).then((res) => {
return;
}, (e) => {
console.error(e);
});
In the logs for this function, I am getting the error:
{ "error": { "code": 403, "message": "The caller does not have permission", "status": "PERMISSION_DENIED" } }
This error seems like a standard Google API permission denied error response, but when would it happen in a Request Sync HomeGraph API call?
I was having this problem for quite a long time, and I decided to post the question and answer here so others don't have to spend wasted time troubleshooting.
There are two potential causes for this error to occur.
The most logical cause: make sure you provide a valid API key in the data passed in to the smarthome constructor. The example in the question is correct (of course, replace (my key) with the key you made in the console.
This was the cause of the error that I ran in to: make sure the uid you pass in to requestSync() is a valid user ID. There was a flaw in my SYNC code, therefore the user did not get created. I struggled so much on diagnosing this problem because the error message does not make sense.
Hope this helps to anyone with this problem.

Cannot get REST API response error messages in Outlook Add-ins

I was developing a few Office Outlook Web Add-ins and in none of them could I receive an response error message. Independently of the error that API returns I receive the following data object in fail function:
readyState: 0
responseText: ""
status: 0
statusText: "error"
withCredentials: true
Moreover in the Visual Studio or Browser JavaScript Console console I get:
Origin https://localhost:44347 not found in Access-Control-Allow-Origin header.
XMLHttpRequest: Network Error 0x80700013, Could not complete the operation due to error 80700013.
I would like to point out that CORS is enabled on the server, and I got this error independently from the action taken. It is the same when I give wrong parameter or make a typo in url.
I would also like to point out that API is OK, and such a thing does not happen when I request using JS in the browser (out of Office) or applications. I get a normal error messages from the server then.
In the example above the test is from localhost, but exactly the same situation is when hosted on remote web server.
What is wired about this is that I normally get success replies (with code and message).
What I would like to achieve is to get an error response as the server returns them. It is really hard to notify user what may be wrong with his request without this info.
[Edit]
For example, when I do the following request in a Outlook Add-in and I set the fake token I receive the mentioned error (or rather no error):
$.ajax({
type: 'GET',
url: API_URL + "/api/rooms/",
beforeSend: function (xhr) {
$.ajaxSettings.beforeSend(xhr);
xhr.setRequestHeader("Authorization", "Bearer " + token);
},
contentType: "application/json",
});
However, when I do the save request using Advanced REST Client I got 403:
"description": "You do not have permission to perform this action.",
"message": "",
"code": "permission-denied",
"status": "fail"
It happens in all Outlook version for me.
The issue is that the office add-in is sending a request to your web application over HTTP and the web project that gets created (I'm assuming you're using the Office add-in templates from visual studio) is by default configured for SSL, i.e an HTTPS connection. Whilst this is recommended for production apps, for debugging purposes you can simply click on your web project, then in visual studio click view on the Menu Bar - > then select the properties window -> then set SSL enabled to false. (see attached Image)
https://i.stack.imgur.com/Lvybn.png
Hope this helps!

Resources