OfficeDev / office-js-helpers

[ARCHIVED] A collection of helpers to simplify development of Office Add-ins & Microsoft Teams Tabs
MIT License
126 stars 56 forks source link

redirectUrl problem #130

Open kosnkow opened 5 years ago

kosnkow commented 5 years ago

Hello, I debuging on my https://localhost:3000 some outlook plugin , I am wondering how redirectUrl should be set ? If I set to https://localhost:3000 it does not work.

schmitch commented 5 years ago

it is extremly badly done. however depending on how you created your application the dev server will have some html sites which should be your returnUrl.

Currently if I use yeoman to generate a word-addin it will create the following structure:

.
├── commands
│   ├── commands.html
│   └── commands.ts
└── taskpane
    ├── app
    │   ├── app.component.html
    │   ├── app.component.ts
    │   └── app.module.ts
    ├── authenticator.ts
    ├── taskpane.css
    ├── taskpane.html
    └── taskpane.ts

Now it also depends on the created webpack config which contains plugins like that: HtmlWebpackPlugin which have a filename attribute . if the filename attribute is taskpane.html you can open that page with https://localhost:3000/taskpane.html and thus that should be your redirect uri.

You can also set your redirect uri to window.location however that means that you need to have a block of:

Office.initialize = reason => {
    if (OfficeHelpers.Authenticator.isAuthDialog()) {
        return;
    }

wherever an authenticator could be opened.