Problems with teams desktop calling Microsoft Teams JavaScript client SDK

Copper Contributor

Please refer to the following URL for the SDK used:

https://docs.microsoft.com/en-us/javascript/api/overview/msteams-client?view=msteams-client-js-lates... https://docs.microsoft.com/en-us/javascript/api/@microsoft/teams-js/?view=msteams-client-js-latest


I use the Microsoft Teams JavaScript client SDK to authenticate programs.

In the browser's teams, the pop-up window will pop up normally during identity authentication.

However, when performing identity authentication in the teams desktop, the pop window does not pop up in the teams, but calls the IE browser of windows. This caused a problem with my program.

 

Debug the code:

After executing [initialize()], the SDK does not recognize the desktop environment.(Unrecognized host Client Type)

Caused the default browser to be called when executing [authentication]

What is the reason for this?

Is my initialization incorrect?

9 Replies
We are looking into this. we will update you

@zhy_qian - Could you please let us know if you are trying bot authentication or tab authentication? Please go through the below mentioned links for bot/tab auth.
  1) Microsoft Teams authentication flow for tabs

  2) Authentication flow for bots in Microsoft Teams

 

 

@Meghana-MSFT 

I am trying the tab authentication
Please refer to the picture in the attachment for the code.

In the desktop of teams, when executing the code shown in the attachment, the code does not recognize the current execution environment of the application.(During the observation of the source code, it is found that the value of "hostClientType" is undefined).

As a result, the internal browser of teams desktop is not opened, but the local IE browser is opened.

Opening the local IE browser will cause errors in my application.

Does the team desktop have a built-in browser? And please help check whether the code is correct.

Thank you.

2021-12-14_104206.png2021-12-14_112230.png

@zhy_qian - Could you please go through the following code sample and verify your code - Code sample

 

@Meghana-MSFT 

Hello, thank you very much for your reply. I refer to the sample code.

The authentication code is roughly the same.

Execute "microsoftTeams.initialize()" code first, and then execute "microsoftTeams.authentication.authenticate()" for authentication.

However, in my code, after the "microsoftTeams.initialize()" code is executed, debug the source code of "microsoftTeams.authentication.authenticate()". It is found that the value of "hostClientType" in the code does not exist.

If I can't call the internal browser of Teams desktop, it will affect my application.

Is there a solution?

I have seen the sample provided. Thank you very much.

However, we have already known and tried the method of obtaining the value of hostclienttype in the sample code.
But the problem now is that the SDK source code runtime cannot get the value of hostClientType.

For example:
When we call the SDK with web Teams, we can get [hostClientType = "web"] through the foreground method [microsoftTeams.getContext()].
However, when debugging the beta SDK ("@microsoft/teams-js": "^2.0.0-beta.2"), it is found that [hostClientType = undefined] obtained in the authentication.authenticate method.

I want to know the reason for [hostClientType = undefined] in the source code on the premise that the foreground can obtain the value of hostclienttype?
How to solve it?
Thank you very much.

I have found a solution to the problem that [hostclienttype] cannot be set before, but it has not solved my problem. The previous team client will open the page of the specified website through the browser, and the main page of the team client will directly call the [failurecallback] method that will be called back when the pop-up window is closed.

After the value of [hostclienttype] is set correctly, the team client does not pop up the pop-up page, and directly calls the [failurecallback] method that will be recalled when the pop-up window is closed, but the browser version of teams can pop up the pop-up window normally.

Is there any solution for the team client to call its internal browser pop-up window to pop up the page of the specified website.

@zhy_qian - Teams internal browser is a part of Microsoft Teams product. We do not have control over the internal browser to call/handle the events.