-
Notifications
You must be signed in to change notification settings - Fork 57
SharePoint Online user credentials authentication
Sergei Sergeev edited this page Sep 26, 2018
·
4 revisions
This authentication option uses Microsoft Online Security Token Service https://login.microsoftonline.com/extSTS.srf
and SAML tokens in order to obtain authentication cookie. As soon as cookie obtained, you need to attach it to your http request in order to run authenticated queries against SharePoint Online.
-
username
- required string, username for SharePoint Online, for example [your user]@[your company].onmicrosoft.com -
password
- required string, password -
online
- optional boolean. You can explicitly specify, that your credentials are for SharePoint Online. It solves some issues with custom domains in SharePoint Onlines. See this issue for additional info.
{
username: 'johndoe@contoso.onmicrosoft.com',
password: 'sd46$fFF$'
}
{
headers: {
'Cookie': '<FedAuth authentication cookie>'
}
}
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://[organization].sharepoint.com/sites/dev/', {
username: '[user]@[organization].onmicrosoft.com',
password: '[password]'
})
.then(data => {
var headers = data.headers;
headers['Accept'] = 'application/json;odata=verbose';
request.get({
url: 'https://[organization].sharepoint.com/sites/dev/_api/web',
headers: headers,
json: true
}).then(response => {
console.log(response.d.Title);
});
});
- SharePoint Online
- SharePoint on-premise (2013, 2016, 2019)
- ADFS user credentials
- On demand authentication