Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Config headers not added to digest request. #464

Closed
fela98 opened this issue May 20, 2017 · 3 comments
Closed

Config headers not added to digest request. #464

fela98 opened this issue May 20, 2017 · 3 comments
Assignees
Milestone

Comments

@fela98
Copy link
Contributor

fela98 commented May 20, 2017

Category

[ ] Enhancement

[x] Bug

[ ] Question

Version

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

Expected / Desired Behavior / Question

I want to be able to make non GET requests (modifying requests like POST, PUT, PATCH) to a SharePoint instance while not being on the SharePoint site when sending the request.

Observed Behavior

As the DigestCache doesn't apply the headers supplied in pnp.setup() where the Authorization headers are normally added, you get a 403 response anytime the digest is requested because you're doing a modyfying request.

Steps to Reproduce

Use pnp from an external web application that is on a different domain, and then do any modyfying request.

Inside the digestcache.ts file it uses the HttpClient.fetchRaw() method which doesn't apply any headers from the configuration object. Also the headers from the configuration are not explicitly added to the request. It should be possible to solve the issue by simply applying all headers from the configuration inside digestcache.ts

@fela98 fela98 changed the title Setup headers not added to digest request. Config headers not added to digest request. May 20, 2017
@garrytrinder
Copy link

In the scenario of passing an access token to access SharePoint endpoints, the step to get the request digest is not needed, so should be skipped if the token is present in the request header.

@fela98
Copy link
Contributor Author

fela98 commented May 22, 2017

Ok, I see your point @garrytrinder . This means that there actually are 2 separate problems:

  1. The headers are not added to the digest request.
  2. The digest request should not be sent in the first place if the Authorization header is present (but it is).

You also want to be able to send other headers than the Authorization header which the also should be included in the digest request. For the purpose of separation of concerns I would suggest to have a separate issue and pull request for the 2nd problem.

@patrick-rodgers
Copy link
Contributor

Fixed with merge of #465. Will be in upcoming beta release. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants