Forum Discussion
Use Teams-js for authentication in web
Hi all!
We have an app for Microsoft Teams, Outlook and Microsoft 365. We work with Graph and therefore use teams-js and teamsfx for authentication and token receival.
We would like to give our users the possibility to also run our app in the browser (without Teams / Outlook / Office host). Is there any way we can also use teams-js and teamsfx for token receival? We would like to avoid implementing another library for Microsoft Graph token.
Best regards,
Jens
2 Replies
- Sayali-MSFT
Microsoft
JensK2023- Thanks for reporting your issue.
Are you developing teams app?- Sayali-MSFT
Microsoft
@JensK2023- Yes, you can utilize the teams-js library and teamsfx (Teams Toolkit) to enable your app to run in a browser without the need for Teams, Outlook, or Office hosts. Both teams-js and teamsfx provide functionalities for authenticating and obtaining tokens.
The teams-js library offers a method called authentication.authenticate that can be used to obtain tokens for a specified list of resources. You can call this method in your web app's frontend to trigger the authentication process and obtain the necessary access tokens.
TeamsFx helps to reduce your tasks by using Microsoft Teams single sign-on (SSO) and accessing cloud resources down to single line statements with zero configuration. You can use TeamsFx SDK in the browser and Node.js environments. TeamsFx core functionalities can be accessed in client and server environments.
Reference doc-1. https://learn.microsoft.com/en-us/microsoftteams/platform/toolkit/teamsfx-sdk
2.https://learn.microsoft.com/en-us/microsoftteams/platform/tabs/how-to/authentication/auth-tab-aad?tabs=teamsjs-v2