teams-authenticator
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

Teams Authenticator

Common interface to authenticate inside and outside of Microsoft Teams.

Includes a mock implementation (for testing!) and exports @microsoft/teams-js so you can avoid bundling copies of the SDK.

Getting Started

Using MSAL for authentication requires the registration of an SPA. Follow the MSAL.js 2.0 with auth code flow.

After registering your app you need to configure environment variables for your client. See this tutorial. Specifically, you need to define:

  • CLIENT_ID
  • MSAL_REDIRECT_PATH

// https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/2934

Logging In

If you're inside an iframe the Teams SDK will be used to acquire tokens. You're responsible for calling microsoftTeams.initialize() beforehand.

import { isInsideIframe, microsoftTeams, TeamsAuthenticator } from 'teams-authenticator';


if (isInsideIframe()) {
  microsoftTeams.initialize();
}

const authenticator = new TeamsAuthenticator({
  auth: {
    clientId: <your-client-id>,
  },
});

authenticator.login();

Readme

Keywords

none

Package Sidebar

Install

npm i teams-authenticator

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

21 kB

Total Files

15

Last publish

Collaborators

  • cjsheets