-
Notifications
You must be signed in to change notification settings - Fork 57
Issue with AngularJS $state.provider and redirecting. #19
Comments
A solution for this is following:
Insert this line before your RouterModule gets initialized. In documentation is written that you have to add this line in Office.initialize function. But if it's called after RouterModule you will get problems. Now I got the library running in AngularJS and AngularJS 2. (I build a Word-Add-In) |
Thanks for sharing @stotzout. My approach to that problem is to make that call before the bootstrap itself as I cannot see a reason for any code to run in the popup. For that the So in AngularJS/Angular/React i'd do something like: if(!OfficeHelpers.Authenticator.isAuthDialog()) {
/* bootstrap or do the root level render here */
}
/**
*For react
* render a spinner here to show loading, In Angular, it can be done implicitly
*/ For an example, please look at the Yeoman Generator for Office. |
This library seems to be what I've been looking for, so thanks. I am trying to get it to work with a React Office Add-in, but I don't seem to be able to solve this issue. Is there an example of a React Office add-in that implements the authentication from this library that I could refer to? Thanks |
@Rick-Kirkham @Reezaali : Could you guys update once the Image Extractor sample is complete? @ozippy Thank you 👍. For the moment you could use this sample. Its a React sample for Microsoft Teams but in terms of On a side note, to aid your react development you could use the generator-office to scaffold a React project. |
Hi,
|
I have tried using the Microsoft Teams Todo sample as a basis for getting an Outlook add-in to work. I have used the yo office generator and then retrofitted the same techniques you used in the Teams sample. It seems to work in a normal Chrome window, but when I open an incognito session, open outlook online and try to open the add-in i don't get a dialog. I open the dev tools and in the console, I see the below error; TypeError: Cannot read property 'displayDialogAsync' of undefined Then if I load it again in the incognito window with the dev tools open and debug it, I do get a dialog, but it has the content of the add-in. See attached screen shots. The project is here if you want to see if I am doing something wrong. (It is a bit rough, but I am just trying to get the scaffolding right) https://github.com/ozippy/office1/tree/master/src Thanks |
@ozippy let me take a look at and get back you. |
@Zlatkovsky: Please help in debugging this. I am not sure why the dialog doesn't actually close. |
@ozippy , is there a manifest I could try out in conjunction with the sources you have listed on https://github.com/ozippy/office1/tree/master/src? Or does @stotzout have one? If you have a sample site already published and a manfiest for that that, even better. That way it's easier to pass along to someone on my team who is in charge of the Dialog API, if it's a bug there. |
Hi @Zlatkovsky , the manifest is in the repo here https://github.com/ozippy/office1/blob/master/my-office-add-in-manifest.xml. I just generated a project with Yeoman and made some modifications. At the moment it doesn't do much apart from try to authenticate. I'm not sure my issue is with the dialog closing. It is more that it doesn't display the login in the dialog when in an chrome incognito session. I think you should be able to clone the repo and build/install it. Thanks |
ping @sumurthy. Any ideas/updates? |
@WrathOfZombies & @Zlatkovsky & @ozippy Did you guys find any solution to 'ozzipy' issue with being redirected inside the pop up? |
@rinormaloku let me try it out and get back to you.. And no we haven't found a solution to @ozippy's issue |
The sample worked fine for me. @Zlatkovsky, @sumurthy I am beginning to think this is an issue with the dialogAPI on Outlook. You can take a look at the GIF below. There are only two differences here:
@Reezaali FYI |
@WrathOfZombies I tried this with hello.js and it's redirection worked correctly, even in Outlook. |
@rinormaloku hello.js doesn't use the Office dialog to authenticate and this can be problematic when trying to use the Add-in inside of Desktop/MAC Clients. I am assuming that by redirection you meant that the dialog doesn't close? |
@WrathOfZombies Yes by redirection I mean that the dialog doesn't close. |
@rinormaloku Here's a beta version of OfficeHelpers with an updated dialog logic that should solve most of the problems. https://unpkg.com/@microsoft/[email protected]/dist/office.helpers.js Please give it a try and let me know if you still are seeing issues. (It is a beta version so you might find issues elsewhere) |
The latest version is live at https://unpkg.com/@microsoft/office-js-helpers |
@WrathOfZombies I use the last version of I also tried to generate a new projet with Thanks for your help. |
I'm still having this redirect/callback issue with the latest version of office-js-helpers. I've also tried using the Dialog API, and the issue remains that it is unclear how to handle the redirect. I'm not an expert on routings in a React SPA, especially in the context of the auth flow for an Office add-in - so some guidance on how to set this up would be appreciated. Especially if deeper components like a Login component is used, when conditionally rendered within the parent App component. The crux of the issue is nicely phrased here - I've put a bounty on it: https://stackoverflow.com/questions/43794189/outlook-add-in-office-js-authentication |
I was running into the same issue with my react add-in. In my case, the problem was because I was using "https://localhost:3000" as my redirect URL instead of "https://localhost:3000/taskpane.html". To fix the issue, I had to do the following:
|
TypeError: url.replace is not a function using office-js, when the redirect has happened then I got the above following issue. i am using react |
It's more an information than an issue.
If you are using angularjs router or stateprovider with redirecting, the popup url will immediately redirected to the default url you set.
The result of that is, that the token couldn't read out of the URL from the popup. Additionally the popup doesn't close automatically.
Sometimes it works because in this case the read out was faster than the redirection of angularjs.
The text was updated successfully, but these errors were encountered: