I am unable to download file from SharePoint using Office365-REST-Python-Client.
I am getting then below error: office365.runtime.client_request_exception.ClientRequestException: (None, None, "401 Client Error: Unauthorized for url: https://domain.sharepoint.com/sites/test/_api/Web/getFileByServerRelativePath(DecodedUrl='%2Fsites%2Ftest%2FShared%20Documents%2FSample_Compliance_content.pdf')?$select=ServerRelativePath,Id")
I have went through multiple documents to download the SharePoint file but none of them worked out. Please help me with this error.
So far I have done following steps:
- I signed up for free Developer 365 program.
- Created a site in SharePoint and uploaded a document there.
- I want to download that document using Office365-REST-Python-Client.
- For authorization I did all the steps mentioned in the Office365-REST-Python-Client document.
I followed below steps for authentication as mentioned in the Office365-REST-Python-Client.
- Login to the home page of the Azure Portal
- Navigate to "Azure Active Directory" using the three bars in the top right corner of the portal
- Select "App registrations" in the navigation panel on the left
- Search for and select your relevant application
- In the application's "Overview" page, the client id can be found under "Application (client) id"
- In the application's "Certificates & Secrets" page, the client secret can be found under the "Value" of the "Client Secrets." If there is no client secret yet, create one here.
Below is my code snippet
- I am using ClientCredential to use client id and client secret (not secret id) and ClientContext
- I want to download the pdf file Sample_Compliance_content.pdf in the SharePoint site
- But it is giving me the above mentioned error.
