i tried using https://github.com/JonathanHolvey/sharepy
and i am able to get authenticated, but do not know how to proceed.
- How to get a list of files/documents shared after i login ( like a pwd , and ls in Linux )
- How to get the PATH for the files
- How to get the Auth mechanism used ( i used username and password ) , but from browser we use SSO ( Single Sign On )
here is the code:
import sharepy
from sharepy import connect
from sharepy import SharePointSession
import logging
SPUrl = "https://my.sharepoint.com"
username = 'abcd123'
password = '1234'
site = "https://my.sharepoint.com/:x:/r/personal/601600/_layouts/15/"
s = sharepy.connect(SPUrl,username,password)
# Create header for the http request
my_headers = {
'accept' : 'application/json;odata=verbose',
'content-type' : 'application/json;odata=verbose',
'odata' : 'verbose',
'X-RequestForceAuthentication' : 'true'
}
if not hasattr(s, 'cookie'):
print("authentication failed!"); quit()
else:
# This will return a Requests response object. See the requests documentation for details. s.get() returns Requests response object
r = s.getfile(site,filename = 'DASHBOARD.xlsx')
print (r.status_code)
print (r.raw)
print("Script Complete")
but i get error:
python sharepy_bah.py
Authentication successful
Traceback (most recent call last):
File "sharepy_bah.py", line 31, in <module>
r = s.getfile(site,filename = 'PROGRAM-508-DASHBOARD.xlsx')
File "/Users/syedahmed/opt/anaconda3/envs/pandas/lib/python3.8/site-packages/sharepy/session.py", line 157, in getfile
filename = kwargs.pop("filename", re.search(r"[^/]+$", url).group(0))
AttributeError: 'NoneType' object has no attribute 'group'