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

expatbuilder: ExpatError

Open loriegis opened this issue 2 years ago • 0 comments

I can't connect to my companies' sharepoint site.

I am using company laptop with win10 and python 3.9.

Office365-REST-Python-Client versions: 2.3.11, 2.4 -> I get the ExpatError below. Office365-REST-Python-Client version: 2.2.2 -> I get KeyError: 'SPOIDCRL' (I do not have special characters in the password)

`from office365.sharepoint.client_context import ClientContext from office365.runtime.auth.user_credential import UserCredential from office365.sharepoint.files.file import File

user='xxx' pw="xxx"

auth_site="https://my_company_name.sharepoint.com/sites/knowledgecenter"

conn=ClientContext(auth_site).with_credentials(UserCredential(user, pw))

web=conn.web conn.load(web) conn.execute_query() print(web.properties["Url"])`

I get this error:

`ExpatError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_32432\1469807557.py in 22 web=conn.web 23 conn.load(web) ---> 24 conn.execute_query() 25 print(web.properties["Url"]) 26

~\AppData\Roaming\Python\Python39\site-packages\office365\runtime\client_runtime_context.py in execute_query(self) 132 133 def execute_query(self): --> 134 self.pending_request().execute_query() 135 136 def add_query(self, query, execute_first=False, set_as_current=True):

~\AppData\Roaming\Python\Python39\site-packages\office365\runtime\client_request.py in execute_query(self) 77 request = self.build_request(qry) 78 self.beforeExecute.notify(request) ---> 79 response = self.execute_request_direct(request) 80 response.raise_for_status() 81 self.process_response(response)

~\AppData\Roaming\Python\Python39\site-packages\office365\runtime\odata\odata_request.py in execute_request_direct(self, request) 34 """ 35 self.ensure_media_type(request) ---> 36 return super(ODataRequest, self).execute_request_direct(request) 37 38 def build_request(self, query):

~\AppData\Roaming\Python\Python39\site-packages\office365\runtime\client_request.py in execute_request_direct(self, request) 89 :type request: office365.runtime.http.request_options.RequestOptions 90 """ ---> 91 self.context.authenticate_request(request) 92 if request.method == HttpMethod.Post: 93 if request.is_bytes or request.is_file:

~\AppData\Roaming\Python\Python39\site-packages\office365\sharepoint\client_context.py in authenticate_request(self, request) 228 229 def authenticate_request(self, request): --> 230 self._auth_context.authenticate_request(request) 231 232 def _build_modification_query(self, request):

~\AppData\Roaming\Python\Python39\site-packages\office365\runtime\auth\authentication_context.py in authenticate_request(self, request) 87 :type request: office365.runtime.http.request_options.RequestOptions 88 """ ---> 89 self._provider.authenticate_request(request)

~\AppData\Roaming\Python\Python39\site-packages\office365\runtime\auth\providers\saml_token_provider.py in authenticate_request(self, request) 75 """ 76 logger = self.logger(self.authenticate_request.name) ---> 77 self.ensure_authentication_cookie() 78 logger.debug_secrets(self._cached_auth_cookies) 79 cookie_header_value = "; ".join(["=".join([key, str(val)]) for key, val in self._cached_auth_cookies.items()])

~\AppData\Roaming\Python\Python39\site-packages\office365\runtime\auth\providers\saml_token_provider.py in ensure_authentication_cookie(self) 82 def ensure_authentication_cookie(self): 83 if self._cached_auth_cookies is None: ---> 84 self._cached_auth_cookies = self.get_authentication_cookie() 85 return True 86

~\AppData\Roaming\Python\Python39\site-packages\office365\runtime\auth\providers\saml_token_provider.py in get_authentication_cookie(self) 95 user_realm = self._get_user_realm() 96 if user_realm.IsFederated: ---> 97 token = self._acquire_service_token_from_adfs(user_realm.STSAuthUrl) 98 else: 99 token = self._acquire_service_token()

~\AppData\Roaming\Python\Python39\site-packages\office365\runtime\auth\providers\saml_token_provider.py in _acquire_service_token_from_adfs(self, adfs_url) 137 response = requests.post(adfs_url, data=payload, 138 headers={'Content-Type': 'application/soap+xml; charset=utf-8'}) --> 139 dom = minidom.parseString(response.content.decode()) 140 assertion_node = dom.getElementsByTagNameNS("urn:oasis:names:tc:SAML:1.0:assertion", 'Assertion')[0].toxml() 141

C:\ProgramData\Anaconda3\lib\xml\dom\minidom.py in parseString(string, parser) 1996 if parser is None: 1997 from xml.dom import expatbuilder -> 1998 return expatbuilder.parseString(string) 1999 else: 2000 from xml.dom import pulldom

C:\ProgramData\Anaconda3\lib\xml\dom\expatbuilder.py in parseString(string, namespaces) 923 else: 924 builder = ExpatBuilder() --> 925 return builder.parseString(string) 926 927

C:\ProgramData\Anaconda3\lib\xml\dom\expatbuilder.py in parseString(self, string) 221 parser = self.getParser() 222 try: --> 223 parser.Parse(string, True) 224 self._setup_subset(string) 225 except ParseEscape:

ExpatError: mismatched tag: line 19, column 2`

Could you let me know what am I doing wrong and how could I solve it?

loriegis avatar Apr 13 '23 15:04 loriegis