Python-zeep: NTLM Support

Created on 27 Sep 2016  路  7Comments  路  Source: mvantellingen/python-zeep

Are there plans for supporting NTLM-Auth?

docs help wanted

Most helpful comment

Thank you thank you thank you thank you for writing zeep! SOAP is not my thing, and considering that it was initially designed for / by Microsoft, I was surprised that NTLM authentication was not built into the SOAP modules for python3.

Regardless, I was able to get it to work by reading http://docs.python-zeep.org/en/master/transport.html and installing requests_ntlm and using it with the following code, which needs to have url, userid and password assigned. Note that userid needed to be in the form of DOMAIN\UserName for me.

from requests import Session
from requests_ntlm import HttpNtlmAuth

from zeep import Client
from zeep.transports import Transport

session = Session()
session.auth = HttpNtlmAuth(userid, password)

client = Client(url, transport=Transport(session=session))

All 7 comments

NTLM-Auth can be done by providing your own transport class to zeep.Client and using the requests_ntlm package.

I'll send you a gist when I get to a computer in a bit.

Thanks @RichardRirie, do you want to add an example to the documentation?

Hi @mvantellingen, I should have some time over the weekend to have a look.

This http://docs.python-zeep.org/en/master/transport.html#http-authentication might just cover it for now. If you are able to better document it then I'll happily accept the PR :-)

Thank you thank you thank you thank you for writing zeep! SOAP is not my thing, and considering that it was initially designed for / by Microsoft, I was surprised that NTLM authentication was not built into the SOAP modules for python3.

Regardless, I was able to get it to work by reading http://docs.python-zeep.org/en/master/transport.html and installing requests_ntlm and using it with the following code, which needs to have url, userid and password assigned. Note that userid needed to be in the form of DOMAIN\UserName for me.

from requests import Session
from requests_ntlm import HttpNtlmAuth

from zeep import Client
from zeep.transports import Transport

session = Session()
session.auth = HttpNtlmAuth(userid, password)

client = Client(url, transport=Transport(session=session))

^^ This still works.

Was this page helpful?
0 / 5 - 0 ratings