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:
- HTTPError: 403 Client Error: Forbidden for url via Office365-REST-Python-Client
- Sharepoint Rest API office365 library 403 Client Error
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
Looks like I found a solution.
Instead of using this default XML code for the SharePoint App-Only
I changed Scope to the SharePoint site itself.
Also the trust warning changed and "Let it have full control of all site collections." was gone