Skip to content

cjsheets/teams-authenticator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

// AzureAD/microsoft-authentication-library-for-js#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();

About

Simple implementations of Microsoft Teams authorization strategies for quickly prototyping apps.

Resources

License

Stars

Watchers

Forks

Packages

No packages published