-
Notifications
You must be signed in to change notification settings - Fork 57
SharePoint on premise user credentials authentication
This type of authentication uses http ntlm handshake in order to obtain authentication header.
-
username
- required string, username -
password
- required string, password -
domain
- optional string, domain. Be aware, that either domain or workstation should be provided -
workstation
- optional string, workstation. Either domain or workstation should be provided
For this authentication I recommend using combination of username
, password
and domain
or username
, password
and workstation
(when there is no domain). You can also provide only username
and password
, but that might not work.
For example user [email protected]
need to provided following recommended credential object:
{
username: 'john.smith',
password: 'pass',
domain: 'contoso'
}
You can also provide
{
username: '[email protected]',
password: 'pass'
}
but this configuration might not work for you.
workstation
option is used when you outside domain (in case of SharePoint standalone installation without domains, etc, all in one single computer).
The easiest way to find your current user's domain is to run echo %USERDOMAIN%
in command line.
{
headers: {
'Connection': 'Close',
'Authorization': '<ntlm authorization header>'
},
options: {
agent: keepaliveAgent /* keep alive agent */
}
}
No additional configuration required, since you simply supplying user credentials.
import * as spauth from 'node-sp-auth';
import * as request from 'request-promise';
spauth
.getAuth('https://sp2013dev/sites/dev/', {
username: 'administrator',
password: '[password]',
domain: 'sp'
})
.then(data =>{
let headers = data.headers;
headers['Accept'] = 'application/json;odata=verbose';
let requestOpts = data.options;
requestOpts.json = true;
requestOpts.headers = headers;
requestOpts.url = 'https://sp2013dev/sites/dev/_api/web';
request.get(requestOpts).then(response => {
console.log(response.d.Title);
});
});
- SharePoint Online
- SharePoint on-premise (2013, 2016, 2019)
- ADFS user credentials
- On demand authentication