我开发了一个使用 OfficeJS API 并希望在应用程序中实现 OAuth 的 Outlook 插件,API Documnetation 也
表示Outlook 2016(桌面)支持要求集 1.1、1.2、1.3 和 1.4 但在我的情况下它保持沉默甚至不会引发错误. 在为 word 加载项运行工作对话框 api 示例时,我收到
JavaScript 运行时错误: Unable to get property 'displayDialogAsync' of undefined or null reference
.
我正在使用 Microsoft Office Professional Plus 2016。
我编写的用于启动对话框的代码如下:
dialogTest() {
const url = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?response_type=....";
Office.context.ui.displayDialogAsync(url, { width: 15, height: 27, requireHTTPS: true }, function (asyncResult) {
if (asyncResult.status !== Office.AsyncResultStatus.Succeeded) {
// TODO: Handle error.
return;
}
// Get the dialog and register event handlers.
var dialog = asyncResult.value;
dialog.addEventHandler(Microsoft.Office.WebExtension.EventType.DialogMessageReceived, function (asyncResult) {
if (asyncResult.type !== Microsoft.Office.WebExtension.EventType.DialogMessageReceived) {
// TODO: Handle unknown message.
return;
}
// Parse the message.
var data = JSON.parse(asyncResult.message);
console.log('Hello #Office365Dev', data.name);
// TODO: Do something with the data.
// We got our data, time to close the dialog.
dialog.close();
});
});
}