authentication.authenticate cause Teams Desktop app crash if a pop-up is already open

Muthu Palaniappan 0 Reputation points
2025-03-20T01:41:28.9233333+00:00

I am trying to open a popup using authentication.authenticate from a Teams tab app. The Teams desktop client crashes when attempting to open another popup while an existing popup is still open. Since getting a direct handle for the authentication popup is impossible, it is challenging to check the popup state. Is there a way to detect that the authentication popup is currently open?

Steps to reproduce:

  1. Open a popup using authentication.authenticate from a Teams tab app.
  2. Attempt to open another popup while the first popup is still open.
  3. Observe the crash in the Teams desktop client.

Workaround:

When I attempt to use dialog.url.open, I encountered an error stating, 'There was a problem reaching this app.'

Additional Information:

Teams version: 25060.205.3499.6849

Microsoft Teams | Development
{count} votes

1 answer

Sort by: Most helpful
  1. Sayali-MSFT 3,991 Reputation points Microsoft External Staff Moderator
    2025-03-21T13:31:18.8766667+00:00

    Muthu Palaniappan, Unfortunately, there isn't a direct way to check the state of the authentication popup. However, you can implement a workaround by managing the state within your application. For example, you can set a flag when the popup is opened and reset it when the popup is closed. This way, you can prevent opening a new popup if the flag indicates that one is already open.
    Before opening a new popup, check the isPopupOpen state. If it's true, prevent the new popup from being opened.
    If you encounter the error "There was a problem reaching this app" when using dialog.url.open, ensure that the URL you are trying to open is listed in the validDomains section of your app's manifest. This is crucial for the popup to work correctly in Teams.
    also, make sure that your authentication flow starts and ends on a page that is on your domain. The authenticate() method should open a popup on your domain, redirect to the identity provider, and then call notifySuccess() or notifyFailure() as appropriate.

    Reference Document-

    1. https://learn.microsoft.com/en-us/microsoftteams/platform/tabs/how-to/authentication/auth-tab-aad?tabs=teamsjs-v2#initiate-authentication-flow
    2. https://learn.microsoft.com/en-us/microsoftteams/platform/tabs/how-to/authentication/auth-flow-tab

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.