Today I was working on some customizations in SharePoint Online and I needed to add files to the Master Page Gallery. I could add folders, but when I tried to upload files I got an Access Denied message “Sorry, you don’t have access to this page”:

Master Page Gallery Request Access

Master Page Gallery Request Access

First I checked if the scripting capabilities were turned on, that was the case:

Access Denied Master Page Gallery Scripting Capabilities

SharePoint Online Scripting Capabilities

I also checked my authorizations on SharePoint Online, I was Site Collection Administrator. But still I did not have the permisson to add a file to the Master Page Gallery. When I checked the permissions on the Master Page Gallery itself, I noticed a Deny Permission:

Master Page Gallery Permissions

Master Page Gallery Permissions

It seems that the Custom Script settings in the SharePoint Online Management portal did not reflect the current configuration. To enable scripting on a particular site collection immediately, run the following PowerShell command:

Hopefully you will fix this issue faster than I did using this blogpost!

Reference: https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off