2
votes

I am using zeep to connect to api.

this api wants authentication in headers.

I have api key and i have secret key, now my question is how to use this with zeep? I somehow just don't understand the logic in Zeep documentation, would anyone please be so nice to explain the logic to me. Thank you.

from zeep import Client

auth_key = '1#something'
secret_key = '2#something'

a=Client('https://example?WSDL')
a.service.Getsomething()

output > fail because of wrong auth or secret key

I don't understand as well why Signature is not working with Zeep. I needed to instal xmlsec, but I can't because of some errror with p..config file and I already gave up with this... hopefully i do not need signature for this?

thanks

1
did your documentation tell you what header names to put your keys? - chfw
did you try the wsse package of zeep python-zeep.readthedocs.io/en/master/wsse.html - jan-seins

1 Answers

0
votes

I would reckon passing a lxml element object would be something you can try.

For example:

headers = etree.XML('<header><a><b/></a></header>')

then pass the argument into the request

a.service.Getsomething(_soapheaders=[*headers])