Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

TypeError: Cannot read property 'displayDialogAsync' of undefined #88

Open
binarykitchen opened this issue May 14, 2018 · 2 comments
Open

Comments

@binarykitchen
Copy link

binarykitchen commented May 14, 2018

This error happens when I want to test authentication on https://localhost:3443 for an add-in I'm developing locally:

screen shot 2018-05-15 at 11 21 38

Any clues what it is?

@binarykitchen
Copy link
Author

So, Office.context.ui is undefined. Hmmm, but Office-JS is loaded fine.

@blandine
Copy link

This error happens when trying to use
authenticator.authenticate(OfficeHelpers.DefaultEndpoints.Microsoft, false) in a Dialog.
For example, when trying to follow the recommended workflow : https://docs.microsoft.com/en-us/office/dev/add-ins/design/authentication-patterns :

  1. In add in, the user clicks on a button to authenticate
  2. It open a first dialog box to provide two ways of authentication
  3. The user clicks on "Sign in with Microsoft"

At this point, the office-js-helpers authenticator is called and it tries to open a new Dialog. But it's already in the previous Dialog context, therefore, Excel context is not available anymore.

After reading the code, my pov is : office-js-helpers should know that it's running in a Dialog and launch a web window instead.
I don't know exactly how to check it, maybe around getHostInfo() of office-js-helpers/src/helpers/utilities.ts ?
Or is there an other way?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants