Forum Discussion

Bhavi2803's avatar
Bhavi2803
Copper Contributor
Sep 29, 2023

Accessing file from sharepoint using python

Hi SharePoint community,

I am new to SharePoint, I need your help to read SharePoint file like excel or csv through python script from my local machine. I have used below libraries 

 

from office365.sharepoint.client_context import ClientContext
from office365.runtime.auth.user_credential import UserCredential
from office365.sharepoint.files.file import File
ctx = ClientContext(SHAREPOINT_SITE).with_credentials(UserCredential(USERNAME,PASSWORD))

 and used username and password for authentication purpose but every time I try to connect always getting below error

"An error occurred while retrieving token from XML response: AADSTS53003: Access has been blocked by Conditional Access policies. The access policy does not allow token issuance."

I am not sure how to fix this issue, Do I need to my org admin to provide access or is there any other API I can use to connect.

If some one has done this before please share the steps to create the connection.

Appreciate your help 

 

Thank You

Bhawna Gupta

 

Resources