Я пытаюсь подключиться к SOAP API и выполнить аутентификацию с использованием Windows Аутентификация. Я использую suds-py3 и установил python -ntlm3. Я попытался выполнить то, что было изложено в этом сообщении Stack Exchange , но получаю следующую ошибку: TypeError: ожидаемая строка или байтовоподобный объект. Я относительно новичок в этом и не уверен, как диагностировать эту проблему ... мой код и полный трассировщик приведены ниже. Кто-нибудь может увидеть, что я делаю не так?
TypeError Traceback (most recent call last)
<ipython-input-3-d1f3f5890266> in <module>
2 ntlm = WindowsHttpAuthenticated(username='user', password='pass')
3 url = 'https://xxxxxremovedforpostxxx/winauthwebservices/sswinauthwebservice.asmx'
----> 4 client = Client(url, transport=ntlm)
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\suds\client.py in __init__(self, url, **kwargs)
108 self.set_options(**kwargs)
109 reader = DefinitionsReader(options, Definitions)
--> 110 self.wsdl = reader.open(url)
111 plugins = PluginContainer(options.plugins)
112 plugins.init.initialized(wsdl=self.wsdl)
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\suds\reader.py in open(self, url)
149 d = cache.get(id)
150 if d is None:
--> 151 d = self.fn(url, self.options)
152 cache.put(id, d)
153 else:
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\suds\wsdl.py in `__init__(self, url, options)`
133 log.debug('reading wsdl at: %s ...', url)
134 reader = DocumentReader(options)
--> 135 d = reader.open(url)
136 root = d.root()
137 WObject.__init__(self, root)
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\suds\reader.py in open(self, url)
76 d = cache.get(id)
77 if d is None:
---> 78 d = self.download(url)
79 cache.put(id, d)
80 self.plugins.document.parsed(url=url, document=d.root())
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\suds\reader.py in download(self, url)
92 fp = store.open(url)
93 if fp is None:
---> 94 fp = self.options.transport.open(Request(url))
95 content = fp.read()
96 fp.close()
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\suds\transport\https.py in open(self, request)
59 def open(self, request):
60 self.addcredentials(request)
---> 61 return HttpTransport.open(self, request)
62
63 def send(self, request):
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\suds\transport\http.py in open(self, request)
61 u2request = u2.Request(url, None, headers)
62 self.proxy = self.options.proxy
---> 63 return self.u2open(u2request)
64 except HTTPError as e:
65 raise TransportError(str(e), e.code, e.fp)
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\suds\transport\http.py in u2open(self, u2request)
117 return url.open(u2request)
118 else:
--> 119 return url.open(u2request, timeout=tm)
120
121 def u2opener(self):
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\urllib\request.py in open(self, fullurl, data, timeout)
530 for processor in self.process_response.get(protocol, []):
531 meth = getattr(processor, meth_name)
--> 532 response = meth(req, response)
533
534 return response
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\urllib\request.py in http_response(self, request, response)
640 if not (200 <= code < 300):
641 response = self.parent.error(
--> 642 'http', request, response, code, msg, hdrs)
643
644 return response
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\urllib\request.py in error(self, proto, *args)
562 http_err = 0
563 args = (dict, proto, meth_name) + args
--> 564 result = self._call_chain(*args)
565 if result:
566 return result
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
502 for handler in handlers:
503 func = getattr(handler, meth_name)
--> 504 result = func(*args)
505 if result is not None:
506 return result
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\ntlm3\HTTPNtlmAuthHandler.py in http_error_401(self, req, fp, code, msg, headers)
133
134 def http_error_401(self, req, fp, code, msg, headers):
--> 135 return self.http_error_authentication_required('www-authenticate', req, fp, headers)
136
137
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\ntlm3\HTTPNtlmAuthHandler.py in http_error_authentication_required(self, auth_header_field, req, fp, headers)
38 if auth_header_value is not None and 'ntlm' in auth_header_value.lower():
39 fp.close()
---> 40 return self.retry_using_http_NTLM_auth(req, auth_header_field, None, headers)
41
42 def retry_using_http_NTLM_auth(self, req, auth_header_field, realm, headers):
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\ntlm3\HTTPNtlmAuthHandler.py in retry_using_http_NTLM_auth(self, req, auth_header_field, realm, headers)
100 # some Exchange servers send two WWW-Authenticate headers, one with the NTLM challenge
101 # and another with the 'Negotiate' keyword - make sure we operate on the right one
--> 102 m = re.match('(NTLM [A-Za-z0-9+\-/=]+)', auth_header_value)
103 if m:
104 auth_header_value, = m.groups()
c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\re.py in match(pattern, string, flags)
170 """Try to apply the pattern at the start of the string, returning
171 a match object, or None if no match was found."""
--> 172 return _compile(pattern, flags).match(string)
173
174 def fullmatch(pattern, string, flags=0):
TypeError: expected string or bytes-like object