# teams-authenticator

> Microsoft auth helper for quickly prototyping apps

Latest version **0.0.2** (published 2021-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install teams-authenticator
pnpm add teams-authenticator
yarn add teams-authenticator
bun add teams-authenticator
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2021-03-22 |
| First published | 2021-03-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 20.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Chad Sheets |
| Maintainers | cjsheets |

## Links

- npm: https://www.npmjs.com/package/teams-authenticator
- Repository: https://github.com/cjsheets/teams-authenticator
- Homepage: https://github.com/cjsheets/teams-authenticator#readme
- Issues: https://github.com/cjsheets/teams-authenticator/issues
- npm.io page: https://npm.io/package/teams-authenticator

## Dependencies (2)

- [@azure/msal-browser](https://npm.io/package/@azure/msal-browser.md) ^2.12.1
- [@microsoft/teams-js](https://npm.io/package/@microsoft/teams-js.md) ^1.7.0

## Recent versions

- 0.0.2 (latest) — 2021-03-22
- 0.0.1 — 2021-03-21

## README

# Teams Authenticator

Common interface to authenticate inside and outside of Microsoft Teams.

- Inside Teams: [SDK.authentication.authenticate()](https://docs.microsoft.com/en-us/javascript/api/@microsoft/teams-js/authentication?view=msteams-client-js-latest)

- Outside Teams: [MSAL v2 (@azure/msal-browser)](https://www.npmjs.com/package/@azure/msal-browser)

Includes a mock implementation (for testing!) and exports [@microsoft/teams-js](https://www.npmjs.com/package/@microsoft/teams-js) so you can avoid bundling copies of the SDK.

## Getting Started

Using MSAL for authentication requires the [registration of an SPA](https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-spa-app-registration). 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](https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-spa-app-registration). 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();
```

---
_Source: https://npm.io/package/teams-authenticator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
