sp-pnp-node
SharePoint JavaScript Core Library wrapper helper for Node.js
Last updated
Was this helpful?
SharePoint JavaScript Core Library wrapper helper for Node.js
Last updated
Was this helpful?
Consider using as a successor which soaked the best of
sp-pnp-node
andnode-pnp-sp
libraries. I'm keepingsp-pnp-node
not archived and update it from time to time only because of some production implementations which I'm too lazy to migrate topnp-auth
right away.
sp-pnp-node
provides a simple way for using in Node.js with support of various authentication strategies.
PnPjs Client Side Libraries for Microsoft 365 was created to help developers by simplifying common operations within SharePoint and the SharePoint Framework. Currently it contains a fluent API for working with the full SharePoint REST API as well as utility and helper functions. This takes the guess work out of creating REST requests, letting developers focus on the what and less on the how.
SharePoint Online
SharePoint On-Prem (2019, 2016, 2013)
Can be as simple as 5 lines of code:
sp-pnp-node
has two modes:
ambient init - wraps PnPjs
with promise based auth wizard helper
factory - fetchClientFactory
implementation
When to use ambient init: in scripts with user interaction involved when there is no information about authentication and target invironment before script is executed. SharePoint url and the creds are prompted in a console.
In CI/CD scenarios, factory approach is recommended over interactive console as it can lead to a task stuck.
Ambient init example
Factory example
siteUrl?: string; // Optional SPWeb url
configPath?: string; // Path to auth config .json | Default is './config/private.json'
encryptPassword?: boolean; // Encrypts password to a machine-bind hash | Default is 'true'
saveConfigOnDisk?: boolean; // Saves config .json to disk | Default is 'true'
No initial settings (defaults): wizard approach, covers console applications cases with user interaction
With explicitly defined authOptions
:
external tools is in charge for preparing auth credentials in node-sp-auth
format
credentials should not be dumped on disc
Config file with prepopulated credentials: schedule, job automation, continues integration
SharePoint On-Premise (2013, 2016):
User credentials (NTLM)
Form-based authentication (FBA)
Add-In Only permissions
ADFS user credentials
SharePoint Online:
User credentials (SAML)
Add-In Only permissions
ADFS user credentials
authOptions?: IAuthOptions; node-sp-auth
config?: IAuthConf; node-sp-auth-config
Settings can be left blank. Auth options in such a case will be asked by node-sp-auth-config
in a wizard like approach.
This project was inspired by and . Main ideas were taken from and . The result project implements the same concepts with a goal of reusability and maintenance simplification.