npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

msal-electron-poc

v0.1.0

Published

Microsoft Authentication Library for Electron Proof of Concept

Readme

Microsoft Authentication Library for Electron Proof of Concept

The MSAL library for Electron enables cross-platform Electron desktop applications to authenticate users using Azure AD work and school accounts (AAD) as well as Microsoft personal accounts (MSA). It also enables your Electron app to get tokens to access Microsoft Cloud services such as Microsoft Graph.

Installation

Using NPM:

npm install msal-electron-poc

Additionally, since the library uses electron as a peer dependency, you must have electron installed in your project as a devDependency or in your local machine. If your project is already setup, you may have already installed Electron. Otherwise, use the following command in your project's root directory:

npm install electron --save-dev

Note: Please use Electron major version 5 (5.x.x) to satisfy MSAL Electron's peerDependency requirement.

What To Expect From This Library

At present, msal-electron-poc is intended to be a proof of concept library in providing authentication to Electron applications using OAuth 2.0's Authorization Code Grant flow and Azure Active Directory.

As such, this library is not recommended for serious projects or applications intended for production.

What MSAL Electron does

MSAL Electron allows Electron applications to authenticate users and acquire access tokens for AAD and MSA accounts. Once a user has been authenticated and an access token has been requested and received, the client application can use said access token to make authorized requests to Microsoft resources such as MS Graph.

OAuth 2.0 and the Authorization Code Flow

MSAL Electron implements the Authorization Code Grant Flow, as defined by the OAuth 2.0 protocol and is OpenID compliant.

Although our goal is to abstract enough of the protocol away so that you can get 'plug and play' authentication, it is important to know and understand the auth code flow from a security perspective in order to use this library.

The auth code flow runs in the context of a native client (a client running directly on a user's device), which falls under the definition of a public client in the OAuth 2.0 spec.

As opposed to confidential clients, public clients cannot guarantee the confidentiality of their credentials given the environment they operate in. In short, the auth code grant is designed as a specific solution to more secure authentication for this specific class of applications.

For more information on the concepts related to the Auth Code Grant flow, refer to the official RFC on OAuth 2.0.

Prerequisites

Before using MSAL Electron you will need to:

You will need the following information in order to configure msal-electron to work with your AAD application:

  • Tenant ID
  • Client ID
  • Authority
  • Redirect URI
    • You must set the Redirect URI on the AAD App yourself.
    • msal-electron-poc uses custom schemes to register a custom file protocol to listen for redirect responses. We recommend you register a Native/Mobile Redirect Address with the form "myappname://authentication"
  • A set of scopes you will be requesting the user's authorization on (i.e. user.read for Microsoft Graph API). Read more about scopes here.

Usage

Once your application has been registered in the Azure portal, you can start using MSAL Electron like in the example below:

import  { PublicClientApplication } from 'msal-electron-poc';
.
.
.
// Configure the PublicClientApplication
const msalAuthConfig = {
    clientId: 'YOUR_AAD_CLIENT_ID'
};

const msalApp = new PublicClientApplication(msalAuthConfig);

Then you can use the PublicClientApplication instance to acquire an access token before making a request to a Microsoft resource API such as MS Graph:

let accessToken;

const tokenRequest = {
    scopes: ['user.read', 'mail.read']
};

try {
    accessToken = await msalApp.acquireToken(tokenRequest);
} catch (error) {
    // add your error handling code
}

You can then use the access token as a Bearer token in the Authorization header of your HTTP request to the Microsoft resource API.

For a complete usage sample, check out our msal-electron-sample-app.

License

Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License (the "License");

We Value and Adhere to the Microsoft Open Source Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.