Forum Discussion

Robin Güldenpfennig's avatar
Robin Güldenpfennig
Brass Contributor
Apr 02, 2017

SharePoint Framework SPFx - change site collection scope

Hi folks,

 

I'm trying to access a List from a different site collection (in this case the MySite of the user).

 

Currently I do it like this with PnP JS Core:

let web = new Web(webUrl);
web.lists.ensure(listTitle);

Then the REST API request "/_api/web/lists/getByTitle('Some list')" fails with a HTTP 403.

 

And when I take a look with Fiddler I can see that all the FedAuth stuff is missing. When I execute the request manually directly on the MySite everything works fine. So my user has the desired permissions.

 

So what is the best practice to "change the context" here and access other site collections than the one where the web part is placed on?

4 Replies

  • paulpascha's avatar
    paulpascha
    Bronze Contributor

    I think this has to do with scripting capabilities being turned off by default for Personal Sites, see the following article:

     

    https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f?ui=en-US&rs=en-US&ad=US&fromAR=1

    • Robin Güldenpfennig's avatar
      Robin Güldenpfennig
      Brass Contributor
      Hi Paul,

      I don't think so because I just want to access the REST API with the PnP JS Core Framework. When I access the API manually it works fine.

      I need to instantiate a new web context where my authentication information is transferred, that's the problem I think.

Resources