I need to work with an API that has several services. All of them require the JSESSION cookie to be authenticated below. However, when I call the following service, it does not save the cookie and therefore rejects them.
from suds.client import Client
url = 'http://example/ws/Authenticate?wsdl'
client = Client(url)
result = client.service.connect(username='admin', password='admin')
print client.options.transport.cookiejar
>>> <cookielib.CookieJar[<Cookie JSESSIONID=XXXXXXXXXX for localhost.local/Service/>]>
I believe that the way to make it save this cookie is to extract it and then provide it as a custom header in the format: -
url = 'http://example/ws/dostuffnowloggedin?wsdl'
client2 = Client(url, headers= { 'Cookie': 'JSESSIONID=value'})
But I canβt figure out how to do this. I looked at the SUDS Docs, URL2LIB and Cookiejar python docs, looked at the stack and asked Reddit. This is the first question I asked in Stack, I tried to make it meaningful and specific, but if I made a mistake, tell me and I will do my best to fix it.
source
share