Error 403: Access Sharepoint using App Credentials in Python

Technology2 0 Reputation points
2024-05-13T23:20:29.6766667+00:00

I am trying to access files stored in SharePoint using Python. I have registered the app in Azure Ad and have client_id and client_secret. I have given the read and write permissions however I am still getting 403 error.

I am not really sure as to what I am missing out on. below is the script:

`from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.client_credential import ClientCredential

site_url = ''
app_principal = {
    'client_id': '',
    'client_secret': ''
}

credentials = ClientCredential(app_principal['client_id'], app_principal['client_secret'])
ctx = ClientContext(site_url).with_credentials(credentials)

web = ctx.web
ctx.load(web)
ctx.execute_query()`
Microsoft Identity Manager
Microsoft Identity Manager
A family of Microsoft products that manage a user's digital identity using identity synchronization, certificate management, and user provisioning.
623 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,793 questions
0 comments No comments
{count} votes