Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cjsheets/teams-authenticator
Simple implementations of Microsoft Teams authorization strategies for quickly prototyping apps.
https://github.com/cjsheets/teams-authenticator
Last synced: 13 days ago
JSON representation
Simple implementations of Microsoft Teams authorization strategies for quickly prototyping apps.
- Host: GitHub
- URL: https://github.com/cjsheets/teams-authenticator
- Owner: cjsheets
- License: mit
- Created: 2021-03-21T02:46:13.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-03-22T17:10:47.000Z (over 3 years ago)
- Last Synced: 2024-10-20T07:44:17.623Z (about 1 month ago)
- Language: TypeScript
- Size: 42 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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: ,
},
});authenticator.login();
```