Today, a colleague was working in some customizations in SharePoint Online and he needed to access to the Master Page Gallery, he could access using the url, but when he tried to upload files he received the typical Access denied message.
I catch an eye to this weird behaviour and I realized that this was happening for any Site Collection administrator, so what was happening? tracking the issue we were able to discover by Check permission that the permission of “Adding or Customizing Pages” was denied in that library.
So my next step was to check if the scripting capabilities were turned on, in our case how the tenant was new the feature was set to Prevent, so I changed it to Allow
MS says that it is necessary to wait at least 24 hours to see the changes, but if you’re in a hurry and don’t want to waste your time, open your PowerShell Shell and execute the following:
Set-SPOsite “https://urltenant.sharepoint.com” -DenyAddAndCustomizePages 0
Once executed, the option of master page gallery will appear in the settings panel, so my colleague could continue with his work.
Hope it helps!