Skip to content

401 against on-premises when using containers #128

Description

@chanm003

'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"]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions