Friday, 16 October 2020

python sharepoint - Error validating credentials due to invalid username or password

I want to automate downloading a zipfile on another organization's sharepoint site that they have shared with my organization, inviting us as a guest using a generic company email address so we can access the files. To gain access, I provide the company email address as username and its associated AD password which authenticates access through our MS 365 organization account.

This works fine manually, but when attempting to do it through shareplum I get a credentials error.

Here is my code:

from shareplum import Site
from shareplum import Office365
from shareplum.site import Version

sharepointUsername = 'elvis.presley@suspiciousminds.org'
sharepointPassword = 'oogabooga123'
sharepointSite = 'https://abc.sharepoint.com/sites/ClientLogin/Shared Documents/Graceland/'

authcookie = Office365(website, username=sharepointUsername, 
             password=sharepointPassword).GetCookies()
site = Site(sharepointSite, version=Version.v365, authcookie=authcookie)

And here is the error:

Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "C:\arcgispro-py3-clone2\lib\site-packages\shareplum\office365.py", line 88, in get_cookies
    sectoken = self.get_security_token(self.username, self.password)
  File "C:\arcgispro-py3-clone2\lib\site-packages\shareplum\office365.py", line 80, in get_security_token
    raise Exception('Error authenticating against Office 365. Error from Office 365:', message[0].text)
Exception: ('Error authenticating against Office 365. Error from Office 365:', 'AADSTS50126: Error validating credentials due to invalid username or password.')

Any clue as why this is not working? I've checked the credentials several times using them to log in manually and it works every time (obviously the example does not have the real username/password)?



from python sharepoint - Error validating credentials due to invalid username or password

No comments:

Post a Comment