1

I am trying to develop an Excel add-in with custom functions and a task pane that interacts with an existing remote web application, to which I have added pages that load OfficeJS and my custom functions. The service uses cookie-based session authentication after login. What's the simplest way to get authentication working in the fetch requests used in my custom formulas? Do I have to use the Office Dialog API for auth? I can do local sign-in in the Taskpane directly - why would I need to use the Office Dialog API?

Once I have a valid authenticated browser session, can I use that session in a shared runtime to automatically authenticate the ajax requests made by my custom functions? I have tried to get a shared runtime going to test this, to no avail. My manifest is valid, the Add-in will install via sideload, and the task pane will load, but when I execute a custom function the shared runtime tries to start and then times out, with no error message in the runtime log. Addin Error Message

Andrew
  • 1,698
  • 14
  • 15
  • Hey there, you'll need to use the Shared Runtime if you're using cookie based session authentication. By default custom functions, run in a seperate javascript runtime which optimizes memory but as it runs in its own sandbox, there isn't a great way for us to share cookie state. For your error below, can you provide more details. - What version number of windows/Office are you using? (Currently the shared runtime has a dependency on IE11 as it uses that browser context). - Do you have an example/sample manifest to share? – Keyur Patel - MSFT Dec 15 '20 at 17:15
  • @KeyurPatel-MSFT here is an example with placeholders. The structure of my manifest is identical to this. I'm currently running on internal URLs on http but will eventually be using https. The functions are just the sample functions generated by yo-office. My office version is O365 64bit on Windows 10, Office version 16.0.12.527.21378 https://gist.github.com/ajcarmen/502a03694484d83e2cacd578dde9f011 – Andrew Dec 15 '20 at 18:59
  • I tried using the F12 developer tools and was able to connect with IE/Trident and saw some initial requests in the network traffic, but once the above "starting the add-ins runtime" message appeared, I got nothing else in the developer console. – Andrew Dec 15 '20 at 19:07
  • Thanks! I think the core issue is you need https for the functions to run. Can you try with https and see if it fixes things for you? The yo office templates have tooling that sets ups self signed cert you can use for testing. – Keyur Patel - MSFT Dec 15 '20 at 19:09
  • Thanks @KeyurPatel-MSFT I just tried with https-only but I'm getting the same error. Any other ideas? – Andrew Dec 15 '20 at 19:25
  • Hmm, will ask one of our team members from the custom function team to help out and investigate more deeply. – Keyur Patel - MSFT Dec 15 '20 at 19:27
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/226003/discussion-between-andrew-and-keyur-patel-msft). – Andrew Dec 15 '20 at 19:46
  • Thanks for the discussion, Andrew and glad that using shared runtime and starting from one of our templates, solved the issue for you. – Keyur Patel - MSFT Jan 07 '21 at 00:37

1 Answers1

0

Per conversation in comments, to use cookie based authentication for Excel add-ins or custom functions, you need to use the Shared Runtime. You can configure by adding the Runtimes element into your manifest, and use the same resource ID/page for all the components you want shared, which in this case would be your taskpane and your custom function.

<VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
  <Hosts>
    <Host xsi:type="Workbook">
      <Runtimes>
        <Runtime resid="ContosoAddin.Url" lifetime="long" />
      </Runtimes>
      ...

      <Page>
          <SourceLocation resid="ContosoAddin.Url"/>
      </Page>
...

A detailed walk through can be found here: https://learn.microsoft.com/en-us/office/dev/add-ins/tutorials/share-data-and-events-between-custom-functions-and-the-task-pane-tutorial