【发布时间】:2019-01-08 08:09:17
【问题描述】:
背景: 我有一个 Outlook 插件,它基本上打开了一个登录对话框,该对话框打开了我网站上托管的插件页面,从这里用户被重定向到 auth0,从那里他被重定向到 login.live.com 并发布 auth 我得到一个代码或一个错误再次返回我网站上的另一个页面。
现在,在 Outlook 胖客户端中一切正常。当我手动关闭对话框时,我会在父级中获得正确的错误代码。
问题: 在我的网站上使用 OWA 并托管插件代码时,控件不会返回到对话框中的部分。
我已经在“AppDomains”中添加了用户可以访问的所有网址。并确认父窗口和子窗口都托管在同一个域(和子域)上。
代码
manifest.xml
<AppDomains>
<AppDomain>https://auth0url.auth0.com</AppDomain>
<AppDomain>https://localhost</AppDomain>
<AppDomain>https://login.live.com</AppDomain>
<AppDomain>https://login.microsoftonline.com</AppDomain>
<AppDomain>https://my.website.com</AppDomain>
index.html (Opener Html)
<!-- Load the Office JavaScript APIs -->
<script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/Office.js" type="text/javascript"></script>
<script src="index.js"></script>
index.js
// height and width are percentages of the size of the screen.
Office.context.ui.displayDialogAsync(fullUrl, {height: 45, width: 55, displayInIframe: false},
function (asyncResult) {
console.log(asyncResult);
if (asyncResult.status === "failed") {
//Error code 12009 means "user chose to ignore the dialog box"
if (asyncResult.error.code === 12009) {
// Handle failure
} else {
// Do something else
}
} else {
dialog = asyncResult.value;
dialog.addEventHandler(Office.EventType.DialogMessageReceived, handleToken);
dialog.addEventHandler(Office.EventType.DialogEventReceived, dialogClosing);
}
});
popupRedirect.js(仅托管在我的网站上(与父窗口相同)此文件将 json 字符串触发回父窗口)
Office.initialize = function() {
$(document).ready(function () {
// Some Code before this and after this not relevent to issue
var messageObject = {outcome: "something"};
// Tell the task pane about the outcome.
Office.context.ui.messageParent(jsonMessage);
...
});
});
预期结果:
“messageParent”应该触发index.js的“handleToken”中写的代码
实际结果(可能相关也可能不相关)
appsforoffice.micros…16.01.debug.js:8202 Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('auth0url.auth0.com') does not match the recipient window's origin ('https://my.website.com').
handleToken 中编写的代码不会被触发。
请注意:displayInIframe: true 不起作用,因为 login.live.com 不允许 iframe。
使用的测试环境:
Google Chrome 71.0.3578.98(官方版本)(64 位)(同类群组:稳定) 修订版 15234034d19b85dcd9a03b164ae89d04145d8368-refs/branch-heads/3578@{#897} 操作系统视窗 10 JavaScript V8 7.1.302.31 闪存 32.0.0.101
【问题讨论】:
标签: office-js outlook-web-addins outlook-web-app