New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vestfoldfylke/msal-token

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vestfoldfylke/msal-token

Small wrapper around msal-node for getting tokens from Microsoft (with certificate or secret)

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-91.67%
Maintainers
1
Weekly downloads
 
Created
Source

msal-token

Small wrapper around msal-node for getting tokens from Microsoft (with certificate or secret)

Install

npm i @vestfoldfylke/msal-token

Prerequisities

  • An app registration with permissions to whatever your scope is
  • A secret or a certificate with in PFX format (can e.g. be created in an azure keyvault) added on the app registration (secrets and certificates tab)

Create a secret

  • Go to app registrations "secrets and certificates"
  • Create a new secret
  • Store the secret somewhere safe (you won't see it again after creation)

Add certificate to app registration

  • Go to app registrations "secrets and certificates"
  • Upload the certficate
  • Copy the thumbprint of the certificate

Usage

const { getAccessToken } = require('@vestfoldfylke/msal-token')

// Secret version
const authConfigSecret = {
    clientId: CLIENT_ID, // app reg client id
    tenantId: TENANT_ID,  // tenant id
    clientSecret: CLIENT_SECRET, // client secret
    scopes: TOKEN_SCOPES // scopes for the token, e.g ["https://graph.microsoft.com/.default"]
}

// PFX-certificate version
const authConfigPfx = {
    clientId: CLIENT_ID, // app reg client id
    tenantId: TENANT_ID,  // tenant id
    thumbprint: THUMBPRINT, // Certificate thumbprint
    pfxcert: PFX_CERT_AS_BASE64, // PFX cert as base64
    privateKeyPassphrase: PFX_PRIVATE_KEY_PASSPHRASE || null, // password for private key if needed
    scopes: TOKEN_SCOPES // scopes for the token, e.g ["https://graph.microsoft.com/.default"]
}

const token = await getAccessToken(authConfigSecret || authConfigPfx)

Keywords

FAQs

Package last updated on 01 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc