Unable to define the sites for an App Registration for SahrePoint with Site.Selected

john john Pter 300 Reputation points
2024-09-17T14:05:06.29+00:00

I have this App registration with Site.Selected:-

User's image

now i want to define the sites for the above "Sites.Selected", so i tried the following:-

$siteUrl = "https://*.sharepoint.com/sites/integration-prod"

$clientId = "2**0a"

$certThumbprint = "7**EA"

$tenant = "**.onmicrosoft.com"

Connect-PnPOnline -Url $siteUrl -ClientId $clientId -Thumbprint $certThumbprint -Tenant $tenant

$writeperm = Grant-PnPAzureADAppSitePermission -Permissions "Write" -Site $siteUrl -AppId $clientId -DisplayName "SPGPIntegration-Test"

$PermissionId = Get-PnPAzureADAppSitePermission -AppIdentity $clientId

Set-PnPAzureADAppSitePermission -Site $siteurl -PermissionId $(($PermissionId).Id) -Permissions "FullControl"

but i got these errors:-

User's image

PS C:\Users\mohan> $writeperm = Grant-PnPAzureADAppSitePermission -Permissions "Write" -Site $siteUrl -AppId $clientId -DisplayName "SPGPIntegration-Test"

Grant-PnPAzureADAppSitePermission: {"error":{"code":"AccessDenied","message":"Either scp or roles claim need to be present in the token.","innerError":{"date":"2024-09-17T14:01:55","request-id":"38072694-80cf-4235-9b4c-3d0335ee72ff","client-request-id":"38072694-80cf-4235-9b4c-3d0335ee72ff"}}}

PS C:\Users\mohan>

PS C:\Users\mohan> $PermissionId = Get-PnPAzureADAppSitePermission -AppIdentity $clientId

Get-PnPAzureADAppSitePermission: Forbidden (403): Either scp or roles claim need to be present in the token.

PS C:\Users\mohan>

PS C:\Users\mohan> Set-PnPAzureADAppSitePermission -Site $siteurl -PermissionId $(($PermissionId).Id) -Permissions "FullControl"

Set-PnPAzureADAppSitePermission: Cannot validate argument on parameter 'PermissionId'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.

any advice on this please?

Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,943 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,489 questions
Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,861 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,585 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 105.1K Reputation points MVP
    2024-09-17T16:21:46.9733333+00:00

    Are you trying to authenticate via the application shown on the first screenshot? This will not work, as you need the Sites.FullControl.All for this operation.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.