s-KaiNet / node-sp-auth

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

401 against on-premises when using containers #128

Open chanm003 opened 1 year ago

chanm003 commented 1 year ago

'npm start' works without issues when not using containers, but 401 when containerized. Three files of project are posted below: 401-when-running-inside-container

index.js

const spauth = require("node-sp-auth");
const request = require("request-promise");

spauth
  .getAuth("http://20.107.64.34", {
    username: "SP2016-FARM-ADMIN",
    password: "njdfignds4<LP_",
    domain: "SOCAFRICA",
  })
  .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://20.107.64.34/_api/web";

    request.get(requestOpts).then((response) => {
      console.log(response.d.Title);
    });
  });

package.json

{
  "name": "spnodeauth-docker",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "keywords": [],
  "author": "Mike Chan",
  "license": "ISC",
  "dependencies": {
    "node-sp-auth": "^3.0.7",
    "request-promise": "^4.2.6"
  }
}

Dockerfile

FROM node:16

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

CMD ["npm", "start"]
DakotaWray2 commented 7 months ago

@chanm003 Did you discover a solution?

koltyakov commented 7 months ago

Maybe something related to windows? As the a can't repro a similar ticket issue (works for me).

Does it work for you outside Docker?

UPD: I see this ticket is old, unlikely we'll get a response.