Skip to content

nodejs + getPaged / getNext [403] Forbidden with custom header (ADAL) #31

@eirikb

Description

@eirikb

Category

  • Enhancement
  • Bug
  • Question
  • Documentation gap/issue

Version

Please specify what version of the library you are using: [ 1.0.3 ]

Expected / Desired Behavior / Question

Running the getPaged method, then getNext will throw a [403] Forbidden when using ADAL (custom Authorization header).
I suspect it could be because headers are not copied over in getNext.

Steps to Reproduce

This is my demo-code

const pnp = require('@pnp/sp');
const fetch = require('node-fetch');

const settings = require('./settings.json');

global.fetch = fetch;
global.Request = fetch.Request;
global.Headers = fetch.Headers;

(async () => {
  const sp = pnp.sp.configure({
    headers: {
      Authorization: `Bearer ${settings.token}`
    }
  }, settings.url);

  let page = await sp.web.getList(settings.list).items.select('Id').getPaged();
  // This throws a 403
  await page.getNext();
})();

settings.json has the token hard coded (for testing purposes), a (absolute) URL to the SharePoint Online SPWeb and a server relative URL to a list.

Note, this also affects getAll, since this method uses getPaged.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions