We are building an Outlook addin in which we are trying to do an authentication flow with the following steps:
- Calls
Office.context.ui.displayDialogAsync()
to open a dialog with the URL of an OAuth sign in page (The domain of this page is also added to the "AppDomains" tag of our manifest, in addition to that of our addin). - The user signs in and triggers the authentication.
- Once 2. is done, the OAuth flow redirects back to a page under the same domain of the addin.
- The OAuth redirect page in 3 calls
Office.context.ui.messageParent()
and posts the OAuth token back to the addin. And following is the HTML content of the redirect page.
<script type="text/javascript" src="<URL to the server we host Office JS>/office.js"></script>
<script type="text/javascript">
Office.initialize = function () {
Office.context.ui.messageParent(window.location.hash);
};
</script>
This has been working well on Outlook 2016 and Chrome.
However, it does not work on IE11/Edge sometimes and breaks in step 4. The redirect page cannot perform Office.context.ui.messageParent(). We see when this happens, there is a "warning office.js is loaded outside of office client" in the developer tool and Office.context.ui
appears to be null.
We also found out, turning off IE -> Internet options -> Security -> "Enable Protected Mode" solves this problem. For Edge, according to this page, there is no way to turn that mode off. (We do see it works in some instances of IE/Edge even with this mode to be on).
According to this doc, looks like the issue is the "protected mode" does not allow office.js loads in the redirect page which is outside the office client. But, the redirect page is under the same domain of our addin.
We want to get some insight on this and how to solve this issue. Thanks!