We had C# code to provision a new site using PnP C# library with XMLTemplateProvider, that used to work from past 6+ years. Recently, we are facing the following error while trying to check out the Master Page Gallery.
Appreciate, if someone could share why we are getting this error and what has changed recently in SharePoint?
using (var repositoryContext = new AuthenticationManager().GetAppOnlyAuthenticatedContext(templatesSiteUrl,clientId,clientSecret)) {
var mpgallery = web.GetListByTitle("Master Page Gallery");
mpgallery.ForceCheckout = true;
mpgallery.Update();
web.Context.ExecuteQueryRetry();
}
Error: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))