s-KaiNet / node-sp-auth

Unattended SharePoint http authentication with nodejs
MIT License
137 stars 56 forks source link

asmx call #76

Open xsolon opened 4 years ago

xsolon commented 4 years ago

Could you help with this? Doesn't seem to work for asmx services. I'm getting a 401 error

` spauth.getAuth(siteUrl, settings) .then(options => {

    let headers = options.headers;
    headers['Content-Type'] = 'text/xml';
    headers['SOAPAction'] = 'http://schemas.microsoft.com/sharepoint/soap/GetSite';

    var data = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetSite xmlns="http://schemas.microsoft.com/sharepoint/soap/" /></soap:Body></soap:Envelope>';

    request.post(siteUrl + '/_vti_bin/SiteData.asmx', {
      body: data,
      headers: headers
    }).then(response => {
      debugger;
      //process data
    });
  });`
s-KaiNet commented 4 years ago

Which kind of auth do you use?

xsolon commented 4 years ago

Cloud AppOnly credentials

s-KaiNet commented 4 years ago

App-only creds don't work with asmx services. You could try user\password auth instead.