1.0.9 • Published 4 months ago

msal-simple-helper v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

MSAL-SIMPLE-HELPER

Simple wrapper around MSAL4JS allowing for just a single login (which in many cases is enough)

Installation:

npm i msal-simple-helper

Usage:

import { msalLogin, msalGetAccessToken, msalLogout, AuthConfig } from 'msal-simple-helper'

// Prepare your Azure Entra ID data
const authConfig: AuthConfig = {
      tenantId: yourTenantId,
      clientId: yourClientId,
      // scopes: [your_scope_1, your_scope_2]
    }
    
// Log in (currently, tries to login silently then performs popup login if silent login fails)    
const loginResult = await msalLogin(authConfig)

// msalLogin returns login response from MSAL, so you can use the data as you want to
console.log('Logged in username:', loginResult.acccount.name)

// Get access token
const tokenResponse = await msalGetAccessToken();

// msalGetAccessToken returns access token response from MSAL
// so you can pass the access token like this:
// console.log('Authorization: Bearer ', tokenResponse.accessToken)

// Finally, logout
await msalLogout()
1.0.9

4 months ago

1.0.8

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago