Skip to content

Instantly share code, notes, and snippets.

@sandromello
Last active August 29, 2015 14:19
Show Gist options
  • Save sandromello/7277e7e12efec8c582b0 to your computer and use it in GitHub Desktop.
Save sandromello/7277e7e12efec8c582b0 to your computer and use it in GitHub Desktop.
Get User Zimbra Token
import requests
soapEnvelope = """<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header>\
<context xmlns="urn:zimbra"><nosession/></context></soap:Header><soap:Body><AuthRequest xmlns="urn:zimbraAccount">\
<account by="name">%s</account><password>%s</password></AuthRequest></soap:Body>\
</soap:Envelope>""" % ('usuario@dominio', 'senha')
headers = {
'Content-Type' : 'text/soap+xml'
}
zimbraUrl = 'https://host_ssl/service/soap'
req = requests.post(url=zimbraUrl, headers=headers, data=soapEnvelope)
print req.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment