I need to download a file from a sharepoint which is MSA enabled.Only when i enter credentials and pass through MS authentication, i am able to view that sharepoint link and download that file.
Firstly, i want to know if we can achieve something like this via python script.
To download a file from sharepoint which is MSA enabled.
My code looks like below.
import urllib.request
dls="https://abc.sharepoint.com/:x:/r/sites/ProductImplementation/_layouts/15/Doc.aspx?
sourcedoc=%7B5FFF2D81-8FF4-47BC-ABEF-4E70413561F3%7D&file=Product%20Implementation%20Status-20240531.xlsx"
opener = urllib.request.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
urllib.request.install_opener(opener)
urllib.request.urlretrieve(dls , "testngsheet.xlsx")
When i execute above code, invalid file is downloading and a part of a file content is below.
‘Sign in to your account’
can we achieve this using python. If not python, is there any other feasible way to automate downloading the file from sharepoint.