I have created a very simple SharePoint Online App. It has a manifest and a website. There is a simple script on a Default aspx. It is trying to deploy the file to a Library and getting "Access denied. You do not have permission to perform this action or access this resource." exception when saving to "Style Library", but it saves OK to "SiteAssets".

Here is a code of Default.aspx of my website:

$(document).ready(function () {
        var fileContents = "alert('Hello World');";
        var context = SP.ClientContext.get_current();
        var hostContext = new SP.AppContextSite(context, decodeURIComponent(getQueryStringParameter('SPHostUrl')));
        var web = hostContext.get_web();


        var createInfo = new SP.FileCreationInformation();
        createInfo.set_content(new SP.Base64EncodedByteArray());        

        for (var i = 0; i < fileContents.length; i++) {

        // !!!   magic starts here
        // !!!   Style Library doesn't work (Access Denied)
        // !!!   but SiteAssets does
        var targetFolder = "Style Library";
        // var targetFolder = "SiteAssets";

        var files = hostContext.get_web().getFolderByServerRelativeUrl(targetFolder).get_files();

        context.executeQueryAsync(function () {
            alert("Saved successfully");
        }, function (_, args) {
            alert("Well, it's SharePoint. Error message: " + args.get_message());

And here is my paranoid AppPermissionRequests section of AppManifest.xml file:

    <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl" />
    <AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" />
    <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web/list" Right="FullControl" />

I am using SharePoint Hosted model.

So the question is - why the behaviour is different and how can I really set Full Control level of permissions to my App?

  • You were able to make an auto-hosted app? Microsoft cut those off last year.
    – wjervis
    Mar 9, 2015 at 17:02
  • Hm, it's strange. I choose auto-hosted app, then put my code, run F5 and can see the app added and code is running. But I didn't publish the app, so maybe it's some kind of debug mode...
    – Serhiy
    Mar 9, 2015 at 17:49
  • 1
    Ah, since debug deploys to localhost, it'll probably be good until you publish it. Here is the link where Microsoft announces the cut-off. I believe October was when they shutdown the already running apps.
    – wjervis
    Mar 9, 2015 at 17:55
  • Thanks for useful info. And what about permissions, do you have any idea what am I doing wrong?
    – Serhiy
    Mar 9, 2015 at 18:29
  • With FullControl, it should be working fine. I'd double check that user you are testing with has the permissions to the library.
    – wjervis
    Mar 9, 2015 at 18:31

1 Answer 1


Ok, this is an issue with the settings for your tenant. Basically, to test this you can try to upload a document to the Style Library from the UI. You should be getting the same access denied.

How to solve this?

  1. Go to the SharePoint administration page for your tenant.
  2. Access the Settings page (last item of the left navigation).
  3. Locate the section "Custom Script" and make sure both settings are in "Allow users to run custom..."
  4. Click OK.

It can take up to 24 hs. to make the changes, but you will be able to upload documents to the Style Library back again.

-Hope it helps

  • Hello Rodrigo! Thanks for your answer. I've made changes you've suggested and now waiting for them to be applied. Btw, both settings were "Prevent users ...".
    – Serhiy
    Mar 12, 2015 at 8:05
  • 1
    Yes, this was a new "Feature" MS added a couple of months ago. Suddenly, everything stopped working for us... Mar 12, 2015 at 12:55
  • Thanks, that did the thing! I will be allowed to award the bounty in 7 hours :)
    – Serhiy
    Mar 12, 2015 at 13:04
  • Glad to hear it worked! Mar 13, 2015 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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