sharepoint-adfs
v1.0.1
Published
sharepoint-adfs is a Node.js library for ADFS claims authentication
Downloads
4
Maintainers
Readme
sharepoint-adfs
Are you looking to retrieve SAML token/FedAuth Cookie from SharePoint? Then this is the right package for you.
Description
If your SharePoint site is configured for SAML based ADFS authentication, it helps you to retrieve SAML token and FedAuth cookie. Supports only SharePoint OnPremises and not SharePoint online.
Installation
npm install sharepoint-adfs --save
Usage
Its easy to use. Just import this package in your code, provide necessary inputs to options variable and call required methods.
var sharepoint-adfs = require('sharepoint-adfs');
var options = {
"wa": "wsignin1.0",
"wtrealm": "urn:<your relying party identifier at ADFS server>:",//Ex: urn:mysharepoint:myServer
"wctx": "https://<sharePointSite.com>",//Ex: https://mysharepointsite.domainName
"UserName": "<domain>\\<userName>",
"Password": "Password",
"AuthMethod": "FormsAuthentication",
"adfsServerUrl": "https://<adfsServer>/adfs/ls",//Ex: https://myADFSserver.domain/adfs/ls
"RelyingPartyID": "<relyingparty url from adfs>"//Ex: https://myADFSserver.domain/__trust
};
Get the SAML token or FedAuth Cookie using below functions
var token = sharepointAuth.getSAMLToken(options);
var FedAuthCookie = sharepointAuth.getFedAuthCookie(options);
Call Sharepoint rest
Now you can call Sharepoint REST APIs. Just pass the FedAuth cookie in headers and
give a call to REST URL using request.get
var headers = {
"Accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"Cookie": FedAuthCookie
};
request.get("https://mySharePointSite.com/_api/lists/getByTitle('<listname>')", { headers: headers }, function (err, response, body) {
console.log(response);
});
Getting support
If you face any problems you can mail me [email protected]. Before doing that, please read this file carefully.