Skip to content

johndagostino/sharepoint-auth

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sharepoint authentication using REST

This module will provide you the necessary FedAuth and rtFa cookies along with request digest value using which you will be able to call Sharepoint Online's REST endpoint.

Installation

$ npm install sharepoint-auth

Usage

var Sharepoint = require('sharepoint-auth');

var options = {
    auth: {
        username: '<username>@<your-domain>.onmicrosoft.com',
        password: '<your-password>'
    },
    host: 'https://<your-domain>.sharepoint.com'
}

Sharepoint(options, function(err, result) {
    if (err) {
        // throw it the way you want.
    } else {
        // To get cookies, request digest and request digest timout values
        console.log('FedAuth Cookie', result.cookies.FedAuth);
        console.log('rtFa Cookie', result.cookies.rtFa);
        console.log('RequestDigest Value', result.requestDigest);
        console.log('RequestDigest timeout in seconds', result.requestDigestTimeoutSeconds);
    }
});

See index.js for example.

Pass the retrieved FedAuth and rtFa as shown below in headers

headers: {
  Cookie: 'FedAuth=' + result.cookies.FedAuth + ';rtFa=' + result.cookies.rtFa + ';',
  'X-RequestDigest': result.requestDigest
}

About

Sharepoint authentication

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%