Office-js: OfficeRuntime.auth.getAccessToken via a LaunchEvent action returns error code 5001

Created on 20 Nov 2020  路  4Comments  路  Source: OfficeDev/office-js

I'm trying to make an _Outlook for web_ add-in with Yeoman, configuring it initially for SSO.
From a TaskPanel OfficeRuntime.auth.getAccessToken({ allowSignInPrompt: true }) works just fine.
From an event-based action, OnNewMessageCompose, I get an error code 5001 (Internal error).

Expected Behavior

This is my first add-in, I can't confirm this is a bug but at least I'm calling for help. 馃檹
I expect OfficeRuntime.auth.getAccessToken({ allowSignInPrompt: true }) to return a token.

Current Behavior

This appears in Chrome's browser:

Uncaught (in promise)
OSF.DDA.Error {
name: "Une erreur interne s'est produite", 
message: "Une erreur interne s'est produite", 
code: 5001
}

Steps to Reproduce

  1. Build an add-in with Yeoman like such.
  2. In manifest create a LaunchEvent of type OnNewMessageCompose to change to default signature of the email : this should work.
  3. In the action called by LaunchEvent, ask for token such as const token = await OfficeRuntime.auth.getAccessToken().

Context

I am trying to get user information, as I succeeded via a TaskPanel, to then call a HTTPS server of mine and get signatures for current user.

Your Environment

  • Platform: Outlook for web
  • Host: MailHost
  • Operating System: Windows 10
  • Browser: Google Chrome

Thanks for your help. 馃檹

by design doc bug

All 4 comments

Your observation is correct. Some APIs are not supported in event-based activation. These limitations are mentioned here:
https://docs.microsoft.com/en-us/office/dev/add-ins/outlook/autolaunch#event-based-activation-behavior-and-limitations

Exactly @exextoc , and thank you for your help!

What bugs me is that this doc only refers to getAccessTokenAsync not being supported and not getAccessToken.

I admit I've doubted getAccessToken wouldn't be supported neighter though I'd like a confirmation.

Makes sense. We will update documentation to add 'getAccessToken' API as well explicitly. Thanks for the feedback.

Updated documentation should be published soon.

Was this page helpful?
0 / 5 - 0 ratings