0

I recently created a solution to automate some copy-pasting of Excel files between SharePoint folders.
To establish the connection to SharePoint, I use the Office 365 REST Python client.
As an authentication method, I use clientcredentials (this allowed me to bypass TFA on the SharePoint).
I have verified that the ID and secret that I am using are still valid.

Until recently, the code was working like a charm. Yesterday, however, I got the following error (and have been getting it ever since):

Requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))

Weidly, sometimes I get the following error instead:

File "...\acs_token_provider.py", line 45, in get_app_only_access_token self.error = e.response.text AttributeError: 'NoneType' object has no attribute 'text'

I have encountered several posts mentioning the first error.
However, none of them were related to the package that I am using.
Below is a simplified example of my code which produces the same error:

from office365.runtime.auth.client_credential import ClientCredential
from office365.sharepoint.client_context import ClientContext

CLIENT_ID = "thecorrectclientid"
CLIENT_SECRET = "thecorrectclientsecret"
site_url = "https://{xxxx}.sharepoint.com/sites/{nameofthesite}"
ctx = ClientContext(site_url)
creds = ClientCredential(CLIENT_ID, CLIENT_SECRET)
ctx.with_credentials(creds)
web = ctx.web
ctx.load(web)
ctx.execute_query()
print("Web title: {0}".format(web.properties['Title']))

Does anyone have an idea what may be causing this and how I could possibly fix this?
Any help would be greatly appreciated!

UPDATE: It seems to be a problem related to my local machine.
I just cloned the repo on my other laptop and it runs smoothly.
I have also noticed the following error when opening files from SharePoint (which might be related):

the server you are trying to access is using an authentication protocol not supported by office sharepoint excel

I tried refreshing the Client Id and Client secret (to make sure I wasn't using expired credentials).
I have browsed the web for similar errors, but none of them gave me the answer for my specific situation.
I have double checked if anything changed in the URL of the site that I am trying to access.
I tried running it on another laptop and that worked for me. But the root cause is still a mystery.
No results...

UPDATE: I tried running it on another laptop and that worked for me. But the root cause is still a mystery.

AntnDhg
  • 1
  • 1

0 Answers0