Hi,
we have noticed that our SharePoint AddIn cannot get permissions on a newly created trial O365 tenant.
While getting the ClientContext with ClientID and ClientSecret we get this error "The remote server returned an error: (401) Unauthorized."
We have tried to register a new app-only principal to test if it works on a new tenant by following this documentation from Microsoft:
https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs
After registering and trying again, on the new tenant we got the exact same error "The remote server returned an error: (401) Unauthorized."
But when we tried on an older tenant that we had, it worked fine for both our SharePoint Add-In and for a newly registered principal.
Very simple call using OfficeDevPnP nuget.
OfficeDevPnP.Core.AuthenticationManager am = new OfficeDevPnP.Core.AuthenticationManager();
using (Microsoft.SharePoint.Client.ClientContext context = am.GetAppOnlyAuthenticatedContext(createEntity.AppUrl, clientId, clientSecret))
{
Web web = context.Web;
context.Load(web, w => w.Id, w => w.Title);
context.ExecuteQueryRetry();
}
Is anyone else having the same issue on fresh newly created O365 tenants?
Or maybe there is some new setting to allow using "SharePoint App-Only" authentication?
I have posted the same question to another forum, but was redirected to post here also.
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_sharepoint-mso_win10-mso_o365b/sharepoint-app-only-add-ins-throwing-401/962bfaa2-8604-4e94-ae1c-36ef5b453ed2?tm=1599640808879