Sharepoint Rest API office365 library - 403 Client Error - Permissions Sites.Selected

93 Views Asked by At

I am a global o365 administrator and a users asked me to get access to SharePoint via Pyhton script and he shared me the code from below questions:

I created an Azure App and set permissions to "Sites.Selected" and granted FullControl to needed Sites only. (https://ashiqf.com/2021/03/15/how-to-use-microsoft-graph-sharepoint-sites-selected-application-permission-in-a-azure-ad-application-for-more-granular-control/)

However the user is still getting 403 error and I would like to avoid to setup an app with full control to complete SharePoint tenant.

I tried to find a solution or answer, if the REST API is not working with "Sites.Selected" permissions

1

There are 1 best solutions below

0
tsgwntrbrg On

Looks like I found a solution.

Instead of using this default XML code for the SharePoint App-Only

   <AppPermissionRequests AllowAppOnlyPolicy="true">
      <AppPermissionRequest Scope="http://sharepoint/content/tenant" Right="FullControl" />
    </AppPermissionRequests>

I changed Scope to the SharePoint site itself.

<AppPermissionRequest Scope="https://tenantname.sharepoint.com/sites/sitename"

Also the trust warning changed and "Let it have full control of all site collections." was gone

Screenshot from Example

Screenshot from my App