Error 403: Access Sharepoint using App Credentials in Python

Technology2 5 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.
708 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,854 questions
0 comments No comments
{count} vote

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.