Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

ConnectionError to [myCompany].sharepoint.com

Open sariel-black opened this issue 1 year ago • 3 comments

Hello @vgrem Could you please advise how could I solve this: ConnectionError (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x00000169FBDB00340>: Failed to resolve '[myCompany].sharepoint.com' ([Errno 11001] getaddrinfo fail

As background, we were using sharepoint 2013 in the old time and below code worked super well:

from office365.runtime.auth.authentication_context import AuthenticationContext from office365.sharepoint.client_context import ClientContext import os url="https://team.global.[myCompanyName]/sites/[myTeamName]/" ctx= clientContext(url).with_user_credentials(os.getlogin(), os.getenv('password'), allow_ntlm=True) web = ctx.web.get().execute_query() print("Web title: {0}".format(web.properties['Title']))

After the sharepoint been upgraded to shareapoint 365, our site page becomes: url="https://[myCompanyName].sharepoint.com/sites/[myTeamName]/"

Then we could never connect to the new site page, although by browse or file manager the connecion is fine. We are not allowed to create APP for the site page by the company, so could not try credential as client Id.. By any case you know how we could solve this? most appreciated, thank you.

sariel-black avatar Feb 07 '24 09:02 sariel-black

Greetings,

how about without providing allow ntlm parameter? In SharePoint Online environment NTLM is not supported.

vgrem avatar Feb 10 '24 18:02 vgrem

Thanks for your information, I will check it as soon as possible.

sariel-black avatar Feb 10 '24 18:02 sariel-black

Hello @vgrem, thank you for the reply! Just back to my work, remove ntlm is a good point!

I tried and new errror raise: requests.exceptions.ConnectionError: HTTPSConnectionPool(host='login.microsoftonline.com', port=443): Max retries exceeded with url:/GetUserRealm.srf (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x000002CB8C1B9DC0>: Failed to resolve 'login.microsoftonline.com' ([Errno 11001] getaddrinfo failed)"))

Although remove ntlm is not working yet, but it provides inspiration. When connect to sharepoint online with the browser, it's using oauth2 for authorization. It recalls my memory when working with Azure connection, we used windows powershell: first, set https proxy; second, use command az cli, then there would be a pop up window for login to microsoft, and it's exactly using oauth2, then we could connect to the azure server after this happen.

Just wonder if something similar in it to the sharepoint connection.. Please let me know if you have some thoughts, many thanks!

sariel-black avatar Feb 18 '24 05:02 sariel-black