!This is legacy code and my not work any more for your tenant.
Also this type of Client/Secret is not supported from version 7.0 and onwards of SMART Migration
| Helpful links for creating an Office 365 AppID |
| |
**If you get 401 - Forbidden You may need to run this code and wait 60 minutes.
Set-SPOTenant -DisableCustomAppAuthentication $false
or
Set-PnPTenant -DisableCustomAppAuthentication $false