# @microsoft/mgt-msal2-provider

> The Microsoft Graph Toolkit Msal 2.0 Provider

Latest version **4.7.0** (published 2026-08-28) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @microsoft/mgt-msal2-provider
pnpm add @microsoft/mgt-msal2-provider
yarn add @microsoft/mgt-msal2-provider
bun add @microsoft/mgt-msal2-provider
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.7.0 |
| Published | 2026-08-28 |
| First published | 2021-04-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 210.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1069 |
| Author | Microsoft |
| Maintainers | microsoft1es, microsoft-oss-releases, microsoft-graph-toolkit |
| Keywords | microsoft graph, microsoft graph toolkit, mgt, msal, auth, msal 2.0, authentication |

## Links

- npm: https://www.npmjs.com/package/@microsoft/mgt-msal2-provider
- Repository: https://github.com/microsoftgraph/microsoft-graph-toolkit
- Issues: https://github.com/microsoftgraph/microsoft-graph-toolkit/issues
- npm.io page: https://npm.io/package/@microsoft/mgt-msal2-provider

## Dependencies (3)

- [@azure/msal-browser](https://npm.io/package/@azure/msal-browser.md) ^2.38.3
- [@microsoft/mgt-element](https://npm.io/package/@microsoft/mgt-element.md) 4.7.0
- [@microsoft/microsoft-graph-client](https://npm.io/package/@microsoft/microsoft-graph-client.md) 3.0.2

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 4.7.0 (latest) — 2026-08-28
- 4.7.0-preview.78dad82 (next) — 2026-08-28
- 4.0.0-next.mgt-chat.8627a91 (next.mgt-chat) — 2024-09-05
- 4.0.1-next.electron-provider.74fa189 (next.electron-provider) — 2024-02-23
- 3.1.3-next.mgt-without-loader.701821d (next.mgt-without-loader) — 2024-01-24
- 3.1.3-next.enable-tree-shaking.31b876c (next.enable-tree-shaking) — 2023-10-23
- 3.0.1-next.independent-providers.9468a8b (next.independent-providers) — 2023-07-26
- 3.0.0-rc.3-next.fluentui.5112ceb (next.fluentui) — 2023-06-26
- 3.0.0-rc.3 (preview) — 2023-06-05
- 3.0.0-preview.1-next.fix-grid.a34c8fc (next.fix-grid) — 2023-05-09
- 3.0.0-preview.1-next.preview-pipeline.8bf3848 (next.preview-pipeline) — 2023-03-01
- 3.0.0-next.disambiguation-util-fixes.aecf062 (next.disambiguation-util-fixes) — 2023-02-23
- 3.0.0-next.dark-toggle.5e7a689 (next.dark-toggle) — 2023-02-15
- 3.0.0-next.wc-registration-utils.6ca9b59 (next.wc-registration-utils) — 2023-02-02
- 3.0.0-next.enhanced-file-list.49c3edd (next.enhanced-file-list) — 2023-01-25
- … 747 more at https://npm.io/package/@microsoft/mgt-msal2-provider/versions

## README

# Microsoft Graph Toolkit MSAL 2.0 Provider

> ## ⚠️ Microsoft Graph Toolkit has been retired
>
> As of **August 28, 2026**, the Microsoft Graph Toolkit project has been retired and is no longer maintained. This package will receive no further updates.
>
> Thank you to everyone who built with MGT, filed issues, contributed code, and helped others along the way. This project would not have been possible without your support.
>
> The source code remains available under its existing license. If you would like to continue using or maintaining MGT, you are welcome to [fork the repository](https://github.com/microsoftgraph/microsoft-graph-toolkit) and maintain your own version.

[![npm](https://img.shields.io/npm/v/@microsoft/mgt-msal2-provider?style=for-the-badge)](https://www.npmjs.com/package/@microsoft/mgt-msal2-provider)

The [Microsoft Graph Toolkit (mgt)](https://aka.ms/mgt) library is a collection of authentication providers and UI components powered by Microsoft Graph.

The `@microsoft/mgt-msal2-provider` package exposes the `Msal2Provider` class which uses [msal-browser](https://www.npmjs.com/package/@azure/msal-browser) to sign in users and acquire tokens to use with Microsoft Graph. This provider also supports multiple account logins.


## Usage

1. Install the packages

    ```bash
    npm install @microsoft/mgt-element @microsoft/mgt-msal2-provider
    ```

2. Initialize the provider in code with `Msal2Config`

    ```ts
    import {Providers, LoginType} from '@microsoft/mgt-element';
    import {Msal2Provider, PromptType} from '@microsoft/mgt-msal2-provider/dist/es6/exports';

    // initialize the auth provider globally
    Providers.globalProvider = new Msal2Provider({
      clientId: 'clientId',
      scopes?: string[],
      authority?: string,
      redirectUri?: string,
      loginType?: LoginType, // LoginType.Popup or LoginType.Redirect (redirect is default)
      prompt?: PromptType, // PromptType.CONSENT, PromptType.LOGIN or PromptType.SELECT_ACCOUNT
      sid?: string, // Session ID
      loginHint?: string,
      domainHint?: string,
      isMultiAccountEnabled?: boolean, // True by default, disables multiple account login if false
      isIncrementalConsentDisabled?: boolean, //Disable incremental consent, true by default
      isMultiAccountEnabled?: boolean // True by default, disables multiple account login if false
      isIncrementalConsentDisabled?: boolean, //Disable incremental consent, true by default
      options?: Configuration // msal js Configuration object
    });
    ```

3. Initialize the provider in code with `Msal2PublicClientApplicationConfig` if a `PublicClientApplication` is already instantiated. For example, `msal-angular` instantiates `PublicClientApplication` on startup.

    ```ts
    import {Providers, LoginType} from '@microsoft/mgt-element';
    import {Msal2Provider, PromptType} from '@microsoft/mgt-msal2-provider/dist/es6/exports';
    import {PublicClientApplication} from '@azure/msal-browser';

    // initialize the auth provider globally
    Providers.globalProvider = new Msal2Provider({
      publicClientApplication: PublicClientApplication,
      scopes?: string[],
      authority?: string,
      redirectUri?: string,
      loginType?: LoginType, // LoginType.Popup or LoginType.Redirect (redirect is default)
      prompt?: PromptType, // PromptType.CONSENT, PromptType.LOGIN or PromptType.SELECT_ACCOUNT
      sid?: string, // Session ID
      loginHint?: string,
      domainHint?: string,
      isMultiAccountEnabled?: boolean, // True by default, disables multiple account login if false
      isIncrementalConsentDisabled?: boolean, //Disable incremental consent, true by default
    });

4. Alternatively, initialize the provider in html (only `client-id` is required):

    ```html
    <script type="module" src="../node_modules/@microsoft/mgt-msal2-provider/dist/es6/index.js" />

    <mgt-msal2-provider client-id="<YOUR_CLIENT_ID>"
                      login-type="redirect/popup"
                      scopes="user.read,people.read"
                      redirect-uri="https://my.redirect/uri"
                      authority=""
                      login-hint=""
                      domain-hint="">
    </mgt-msal2-provider>
    ```
  Add the `incremental-consent-disabled` boolean attribute if you wish to disable incremental consent.

5. Multi account login functionality is enabled by default. It can be disabled by adding the boolean attribute `multi-account-disabled` in the html:

    ```html
    <script type="module" src="../node_modules/@microsoft/mgt-msal2-provider/dist/es6/index.js" />

    <mgt-msal2-provider client-id="<YOUR_CLIENT_ID>"
                      login-type="redirect/popup"
                      scopes="user.read,people.read"
                      redirect-uri="https://my.redirect/uri"
                      authority=""
                      multi-account-disabled>
    </mgt-msal2-provider>
    ```

    It can also be enabled/disabled in the `Msal2Config` object:

    ```ts
    import {Providers, LoginType} from '@microsoft/mgt-element';
    import {Msal2Provider, PromptType} from '@microsoft/mgt-msal2-provider/dist/es6/exports';

    // initialize the auth provider globally
    Providers.globalProvider = new Msal2Provider({
      clientId: 'clientId',
      isMultiAccountEnabled?: false
    });
    ```
This feature allows multiple accounts to be signed in at the same time, and the user has the ability to switch between the signed in accounts.

See [provider usage documentation](https://learn.microsoft.com/graph/toolkit/providers) to learn about how to use the providers with the mgt components, to sign in/sign out, get access tokens, call Microsoft Graph, and more.

## Sea also
* [Microsoft Graph Toolkit docs](https://aka.ms/mgt-docs)
* [Microsoft Graph Toolkit repository](https://aka.ms/mgt)
* [Microsoft Graph Toolkit playground](https://mgt.dev)

---
_Source: https://npm.io/package/@microsoft/mgt-msal2-provider · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
