Skip to content
Advertisement

Sharepoint file storage give password expired reason through password not expired using python

Unable to upload the file in SharePoint, since yesterday the code is working fine used stored file in Sharepoint now am getting the below error:

Exception: (‘Error authenticating against Office 365. Error from Office 365:’, ‘AADSTS50055: The password is expired.’)

The same thing happened for the other two accounts even. The function uploadMeta_file(filepath_meta) to call Sharepoint

File “c:UsersDesktopworksamplecookiepopup-kana-api.venvlibsite-packagesshareplumoffice365.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:’, ‘AADSTS50055: The password is expired.’)

JavaScript

Advertisement

Answer

Like you mentioned there is MFA enabled for your account. Looks like you have not handled the same in your application.

There 2 ways to go about this.

  1. Provide Interactive logon UI for handling the MFA.

  2. Create a service account which has the MFA disabled. Thereby using this account to access the Sharepoint Online, you will not encounter the above issue.

  3. Using App Only Authentication

What are Sharepoint app only ?

App only authentication – will not require user credentials but you can get the data by authenticating the App. And Also, app authentication will indirectly bypass MFA (App only authentication are not subjected to MFA).

More information : https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs

I was reading through the Shareplum Tutorials – Unfortunately, but could not get the way to do the App Only Authentication. But you could double check at your end.

If your goal is to use python, you can also use the below library :

https://pypi.org/project/Office365-REST-Python-Client/#Working-with-SharePoint-API

To perform the app only authentication :

JavaScript

But yes, you will have reform your code to perform the required action to make use of the above library.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement