Hi @stramzik ,
I will recommend you to grant access using SharePoint App-Only by the document you have provided. Before you grant Access you could run this cmdlet first Set-SPOTenant -DisableCustomAppAuthentication $false
.For new SharePoint subscription Grant App Permission is disabled by default or the browser link https://xxxx-admin.sharepoint.com/_layouts/15/appinv.aspx is disabled. To enable this feature, we need to connect to SharePoint using Windows PowerShell and then run the cmdlet.
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
$adminUPN="<the full email address of a SharePoint administrator account, example: jdoe@contosotoycompany.onmicrosoft.com>"
$orgName="<name of your Office 365 organization, example: contosotoycompany>"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential
set-spotenant -DisableCustomAppAuthentication $false
Afterward, you can follow the document steps to grant access.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
@RaytheonXie_MSFT
O/p of the ctx.web.execute_query().properties returns an empty JSON string. However while using my actual AD credentials the o/p is a valid json with information about the sharepoint site.
Please note I'm using the ClientCredential() function for the Client ID and Client secret. If I use the Client ID and Client secret in the AuthenticationContext() function as shown in the first block replacing username password. I get "Cannot get binary security token for from https://login.microsoftonline.com/extSTS.srf" error.
I am not really certain what steps were followed by my IT team. They said the required permission has been added to the service principle.
If my code is correct then its most likely the permissions are incorrect should I ask them to folllow the steps in this : https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs#setting-up-an-app-only-principal-with-tenant-permissions documen?