is there any way authenticate by node js ? i want to use node web api using sharepoint 2013 auth by username and password.after user login i will reach sharepoint lists for crud operations. i used node-sp-auth but these codes doesnt work for me. still i am getting 401 error code.

spauth .getAuth('http://domain', { username: 'username', password: 'pass1', host: 'domain' }) .then(data => { let headers = data.headers; headers['Accept'] = 'application/json;odata=verbose'; let requestOpts = data.options; requestOpts.json = true; requestOpts.headers = headers; requestOpts.url = "http://domain/_api/web/lists/getbytitle('cari')/Items?"; request.get(requestOpts).then(response => { console.log(response.d.Title); }) })


Consider sp-request module. It does all authentication for you. You can use REST API without thinking about the auth:

import * as sprequest from 'sp-request';
let spr = sprequest.create(credentialOptions);
  .then(response => {
    console.log('List Id: ' + response.body.d.Id);
  .catch(err =>{
    console.log('Ohhh, something went wrong...');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.