node-sp-auth-config is a utility package designed to simplify the creation and management of authentication configuration files for the node-sp-auth library, which handles unattended HTTP authentication to SharePoint from Node.js applications. It provides a wizard-like interactive CLI experience (`sp-auth`) and a programmatic API for building authentication options. The library supports a wide range of SharePoint versions, including SharePoint Online, 2019, 2016, 2013, and 2010, along with various authentication methods such as user credentials (SAML/ADFS, NTLM), Add-In Only permissions, and Form-Based Authentication. By default, it encrypts sensitive data like passwords using a machine-bound hash. The current stable version is 3.0.5 and it regularly releases updates in conjunction with its core dependency, node-sp-auth. Its primary differentiator is streamlining the often complex setup of SharePoint authentication credentials into a guided, persistent configuration process.
npm install node-sp-auth-configVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to programmatically initialize `node-sp-auth-config` to retrieve SharePoint authentication options. It shows a non-interactive setup using pre-defined credentials, suitable for CI/CD environments, and how the resulting `authOptions` can be used with `node-sp-auth`.
Thoroughly evaluate the security implications of using `node-sp-auth` for your specific use case. Consider alternative, actively maintained SharePoint authentication solutions if continuous security patches are critical. Monitor the `node-sp-auth` GitHub repository for any future updates or community-led forks.
For cross-environment deployments (e.g., CI/CD), avoid relying on disk-saved encrypted passwords. Instead, provide authentication parameters programmatically via the `authOptions` constructor parameter, or use environment variables (e.g., `SPAUTH_SITEURL`, `SPAUTH_USERNAME`, `SPAUTH_PASSWORD`).
In headless environments, ensure all necessary `authOptions` are passed directly in the `AuthConfig` constructor, or that `configPath` points to a pre-existing, fully configured JSON file. Alternatively, ensure the relevant `SPAUTH_` environment variables are set.
Provide all required `authOptions` in the `AuthConfig` constructor or ensure `configPath` points to a valid and complete configuration file. Set `headlessMode: false` to enable interactive prompts during development.
Try using a different Node.js LTS version (e.g., Node.js 16 or 18 if on newer, or Node.js 20+ if on older). For Node.js versions 17 and higher, you might need to run your script with `NODE_OPTIONS=--openssl-legacy-provider node your-script.js` to enable legacy OpenSSL support.
Carefully review all authentication parameters, including `siteUrl`, `tenantId`, `clientId`, `clientSecret`, `username`, and `password`. Verify that the SharePoint Add-In or Azure AD application has the correct permissions and is properly registered and trusted within your SharePoint tenant. For ADFS, confirm the federation service configuration. Check `node-sp-auth`'s issue tracker for similar problems.