I'm trying to write a sharepoint 2013 add-in that reads certain list info from a bunch of site collections i get first and write into an array, however whenever i try to access any sitecollection but the current one the add-in is deployed at, all i get is a login screen with "your connection to this site is not private" and any sharepoint credentials not working, canceling that gives me

app url/_api/SP.AppContextSite(@target)/web/lists@target=%27*site collection url*%27 401 (Unauthorized)

The code i'm currently using is

searchDocumentLibrary2(pathURL, parent) {       

let that = this;
    return new Promise(function (resolve, reject) {
        $.getScript(pathURL + "/_layouts/15/SP.RequestExecutor.js").done(function (script, textStatus) {

            var executor = new SP.RequestExecutor(that.appWebUrl);


                    url: that.appWebUrl + "/_api/SP.AppContextSite(@target)/web/lists?@target='" + pathURL + "'",
                    method: "GET",
                    headers: { "Accept": "application/json; odata=verbose" },
                    success: function (data) {
                      > bunch of stuff

                        resolve(>bunch of stuff);
                    error: function (data) {
                        >bunch of other stuff
                        reject(>bunch of other stuff);


The Add-in does have Tenant permissions.

  • All JavaScript calls to SharePoint will be executed with the user+add-in policy. So the executing user should also have an access to these site collections (and lists). Is this the case?
    – djvuk
    Jul 20, 2016 at 8:23
  • I'm using a user that has access to everything, so yes that is the case
    – Thun
    Jul 20, 2016 at 8:34
  • For cross sitecollection scripts to work you need to give Tenant level permissions to app and also requires Tenant scope deployment
    – Unnie
    Jul 20, 2016 at 9:44
  • As Unnie said i also had to deploy the app tenant scoped, that fixed it, would be good if you posted it as answer so i can upvote it
    – Thun
    Jul 20, 2016 at 11:37
  • @Unnie, please post that as an answer Jul 20, 2016 at 11:52

1 Answer 1


For cross site collection scripts to work in app you have to do below things:

  1. Tenant level permissions
  2. Tenant scope deployment of the app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.