-
Notifications
You must be signed in to change notification settings - Fork 57
On demand authentication
Sergei Sergeev edited this page Mar 1, 2018
·
5 revisions
On demand authentication using interactive browser session.
-
ondemand- required boolean, should be always equal totrue -
electron- optional string, path to your electron executable. If empty, global electron will be used, i.e.electron. ReadConfiguration requiredsection below for details -
force- optional boolean, defaultfalse, whentrueforces electron to show a site with credentials dialog -
persist- optional boolean, defaulttrue, whentrue, saves authentication data on the disk in a user folder in an encrypted manner -
ttl- optional number, explicit cookie expiration time in minutes
{
ondemand: true,
electron: require('electron'),
force: false,
persist: true,
ttl: 60
}{
headers: {
'Cookie': 'FedAuth=77u/PD94bWwgdm....'
}
}On demand option uses electron in order to open SharePoint site url and let you enter credentials. node-sp-auth further reads and optionally (persist option) stores authentication cookies.
If you are building an app with electron, you can require it using credential options: electron: require('electron').
Otherwise you need to explicitly install it globally via npm:
npm install electron -gimport * as spauth from 'node-sp-auth';
import * as request from 'request-promise';
spauth
.getAuth('https://sp2013dev/sites/dev/', {
ondemand: true
})
.then(data => {
let headers = data.headers;
headers['Accept'] = 'application/json;odata=verbose';
request.get({
url: 'https://sp2013dev/sites/dev/_api/web',
headers: headers,
json: true,
rejectUnauthorized: false
}).then(response => {
console.log(response.d.Title);
});
});- SharePoint Online
- SharePoint on-premise (2013, 2016, 2019)
- ADFS user credentials
- On demand authentication