I have created an Outlook Add-in, I am is using SSO to authenticate users, I can not get messageParent to work. Below is what i am doing any help would be greatly appreciated
Page: Weclome.html On Weclome.html on Button click I am opening a dialog box using displayDialogAsync.
$("#btnLoginPopup").click(function () {
//Set up dialog redirct and callback method
Office.context.ui.displayDialogAsync("https://someUrl.co.uk/Login/Login.html", { height: 50, width: 50},
function (asyncResult) {
if (asyncResult.status == Office.AsyncResultStatus.Failed) {
console.log("Could not open login page", event);
}
else {
console.log("Successfully opened");
dialog = asyncResult.value;
dialog.addEventHandler(Office.EventType.DialogMessageReceived, processMessage);
}
});
});
On the same page I have this callback function
function processMessage(arg) {
//close dialog
dialog.close();
console.error("Back");
}
Login.html As soon as this page loads the User is redirected to a external Login page (on a different domain) then they are redirected to a second page LoginCallback.html (on the original domain) after the have been authenticated. When this page load there is a button when clicked should be sending a message back to the parent page but is not working. If I do not have the URL of the external Login in the AppDomains manifest file there is no error but the processMessage function is ever called. If i do have the external url in AppDomains then I get this error
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://SomeUrlAuthUrl.co.uk') does not match the recipient window's origin ('https://SomeUrl.co.uk').
$("#btnLogin").click(function () {
Office.context.ui.messageParent("In", { targetOrigin: "https://someUrl.co.uk/" });
});
Manifest
<AppDomains>
<AppDomain>https://SomeUrl.co.uk</AppDomain>
<AppDomain>https://SomeUrlAuthUrl.co.uk</AppDomain>
</AppDomains>
Thanks
I have tired removing and adding the external url from AppDomains and using
Office.context.ui.messageParent("In", { targetOrigin: "*" })
and
Office.context.ui.messageParent("In")