Access Denied when using SharePoint Add-in Application Permission on new Tenants

Today I ran into 401 HTTP Access Denied Errors when trying to access a M365 Demo Tenants.

I’m still using SharePoint apps when testing App only API functionalities because it is allows faster setup than using an Azure AD App and you do not need a certificate but can work with client secrets.

After some research I found this discussion which gave me a hint: On new tenants authentication using SharePoint Apps is disabled by default. To re-enable it you have to execute the following command using PowerShell:

SharePoint PowerShell

  Set-SPOTenant -DisableCustomAppAuthentication:$false

PNP PowerShell

  Set-PnPTenant -DisableCustomAppAuthentication:$false