Microsoft Graph service exception Error code: accessDenied with Site.Selected Permission

s-taxcomreporting SA 6 Reputation points
2020-12-30T06:33:03.157+00:00

I have application which uploads files from S3 to a specific Sharepoint site using Microsoft graph Java SDK. I registered app called 'S3ToSharePoint' in Azure active directory, add Application type 'Sites.Selected' permission to my app since admin won't grant Sites.ReadWrite.All(Application) for security concern. In the description of 'Sites.Selected', it says 'Allow the application to access a subset of site collections without a signed in user. The specific site collections and the permissions granted will be configured in SharePoint Online. ' So I added this the account as owner(full access) in Sharepoint sites(not sure if this is the correct way to do configuration). But still got 'accessDenied' error when trying to upload to this Sharepoint sites. Does anyone know if this is the correct way? I saw someone use Sites.ReadWrite.All(Application) and that works for them. Not sure 'Sites.Selected' will do the same since it is in preview mode.
sites.selected permission
ClientCredentialProvider and ms graph java sdk upload
accessDenied

Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
{count} votes

9 answers

Sort by: Most helpful
  1. Juan Betancourt 76 Reputation points
    2021-02-25T14:42:13.38+00:00

    Hi @s-taxcomreporting SA , may I ask how did you add the Application as owner in Sharepoint sites?

    So I added this the account as owner(full access) in Sharepoint sites

    0 comments No comments

  2. Jeremy Kelley (SHAREPOINT) 1 Reputation point Microsoft Employee
    2021-03-11T19:03:39.217+00:00

    Just found this question today and wanted to provide some clarity.

    There are two components to making the scenario work.

    1 You already found which is requesting Sites.Selected

    2 Is using the new Permissions API on the Site object (https://learn.microsoft.com/en-us/graph/api/resources/permission?view=graph-rest-1.0) to grant access to your application on each site you want to be able to access.

    To accomplish #2 you will need a separate application that already has Sites.FullControl.All. The intent here is that the application that manages the permissions would likely be owned by your IT or Tenant Admin group since granting permissions requires the necessary broad scope.

    See our blog post (https://developer.microsoft.com/en-us/graph/blogs/controlling-app-access-on-specific-sharepoint-site-collections/) for more details and a demo.


  3. Mohamed Ashiq Faleel 1 Reputation point MVP
    2021-03-15T20:38:55.493+00:00
    0 comments No comments

  4. Wilson Reddy Gajarla 1 Reputation point
    2021-04-05T19:10:51.93+00:00

    SharePoint tenant admin has to approve access to AAD app prior to making call. Tenant admin can user graph explorer to grant permissions. you can refer article for details.

    Make a post request to https://graph.microsoft.com/v1.0/sites/<<siteId>>/permissions for granting permissions to AAD app on the SPO site.
    Headers: Content-Type: application/json
    Body
    {
    “roles”: [“read”],
    “grantedToIdentities”: [{
    “application”: {
    “id”: “<<client id from step 1>>”,
    “displayName”: “<<name of aad app created in step 1>>”
    }
    }]
    }

    0 comments No comments

Your answer

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