Bryan Helmig

Co-founder of Zapier, speaker, musician and builder of things.

SOAP is a bit foreign to me (JSON + good documentation seems so much easier), but I finally managed to authenticate DocuSign with a SOAP client in Python. The code below assumes you have a developer account all set up and have suds, the Python SOAP library, installed:

from suds.client import Client
 
class DocuSign(Client):
    """
    Create a preloaded suds client.
    """
    def __init__(self, username, password, integrator_key, demo=False):
 
        url = 'https://%s.docusign.net/api/3.0/schema/dsapi.wsdl' % 'demo' if demo else 'www'
        location = 'https://%s.docusign.net/api/3.0/dsapi.asmx' % 'demo' if demo else 'www'
        auth = {
            'X-DocuSign-Authentication': '<DocuSignCredentials>' +
                ('<Username>%s</Username>' % username) +
                ('<Password>%s</Password>' % password) +
                ('<IntegratorKey>%s</IntegratorKey>' % integrator_key) +
            '</DocuSignCredentials>'}
 
        super(DocuSign, self).__init__(url, location=location, headers=auth)
 
client = DocuSign(
    username='me@example.com', 
    password='secret', 
    integrator_key='FOOO-6deb3ff9-5479-1241-9287-11f4919c7417', 
    demo=True)
 
print client.service.Ping()

Just follow the DocuSign documentation and suds documentation!


Posted November 4, 2011 @ 10:36 am under Work.