Outlook Desktop hangs on autoevent onMessageComposeHandler when OfficeRuntime.auth.getAccessToken is called

Marco Wassink 0 Reputation points
2023-11-13T15:56:26.2433333+00:00
We have an Outlook web-addin that has the onMessageComposeHandler  associated in the manifest.

A couple of times a day the addin hangs while retrieving an accesstoken. It does not crash, but it just hangs, so we are not able to redirect the user to login or something else.

Most of the day it works. We experienced this sometimes while developing, but now our client is also experiencing this.

Here is a piece of the code:

async function onMessageComposeHandler(event) { 

    mailboxItem = Office.context.mailbox.item; 

 

    try { 

        log("Loading user..."); 

        const accessToken = await OfficeRuntime.auth.getAccessToken({forceConsent: false})
Outlook
Outlook
A family of Microsoft email and calendar products.
3,855 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
983 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Marco Wassink 0 Reputation points
    2023-11-15T14:21:30.5133333+00:00

    solved: it was not the getAccessToken that was hanging.

    we removed the async from the onMessageComposeHandler and replaced the await OfficeRuntime.auth.getAccessToken by OfficeRuntime.auth.getAccessToken.then() and it started working flawless again

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.