Proactive SharePoint Auth

raw JSON →
0.1.0 verified Sat Apr 25 auth: no javascript maintenance

A lightweight Node.js library for authenticating against SharePoint Online and retrieving authentication cookies. Version 0.1.0 is the current stable release. It uses device-level credentials (username/password) to obtain a FedAuth cookie that can be used for subsequent SharePoint API calls. The library is minimal, with no external dependencies, but relies on the deprecated SPO login flow. It only supports username-password authentication (no MFA or app-only). Released irregularly, with no updates since initial version.

error TypeError: proactive.SharePoint is undefined
cause Incorrect import or misspelling of the namespace.
fix
Use correct require: const proactive = require('proactive-sharepoint-auth'); and access proactive.SharePoint.Authenticate.
error Cannot find module 'proactive-sharepoint-auth'
cause Package not installed or not in node_modules.
fix
Run npm install proactive-sharepoint-auth --save
error Request failed with status code 403
cause Authentication credentials are incorrect or MFA is required.
fix
Verify username/password. For MFA-enabled accounts, use an alternative auth method (e.g., app-only).
breaking In version 0.0.1, the API was proactive.SharePoint.Authenticate instead of proactive.SharePoint.Authenticate (capitalization). Mistaking the casing will cause a runtime error.
fix Ensure correct casing: proactive.SharePoint.Authenticate
deprecated Username-password authentication for SharePoint Online is deprecated by Microsoft and may stop working. Use OAuth 2.0 app-only or delegated authentication instead.
fix Migrate to @pnp/nodejs or msal-node with proper OAuth 2.0 flows.
gotcha The authenticate() method returns a cookie string, not an object. Ensure you handle it as a plain string when using in HTTP headers.
fix Set the cookie header as 'Cookie: FedAuth=' + cookie instead of JSON.stringify(cookie).
npm install proactive-sharepoint-auth
yarn add proactive-sharepoint-auth
pnpm add proactive-sharepoint-auth

Authenticates against SharePoint Online and logs the FedAuth cookie.

const proactive = require('proactive-sharepoint-auth');
const auth = new proactive.SharePoint.Authenticate(
  'https://yourtenant.sharepoint.com',
  'user@tenant.onmicrosoft.com',
  'your-password'
);
auth.authenticate()
  .then(cookie => {
    console.log('Authentication cookie:', cookie);
    // Use cookie for SharePoint API calls
  })
  .catch(err => {
    console.error('Authentication failed:', err);
  });