Search code examples
pythondocusignapi

Docusign select signature provider from accounts api object


When I make a call to the Docusign API for list_signature_providers I receive an accounts_api object that has all of my signature provider options and information. I can pass this object as the recipient_signature_providers to my Signers object in the document envelope. However, it will only set the default signer option.

This is what my accounts object contains:

accounts_api = AccountsApi(self.api_client)
providers = accounts_api.list_signature_providers(self._json_token_info['api_account_id'])
print(providers)
{'signature_providers': [{'is_required': 'false',
                          'priority': '0',
                          'signature_provider_display_name': 'DS Electronic',
                          'signature_provider_id': '0',
                          'signature_provider_name': 'universalsignaturepen_imageonly',
                          'signature_provider_options_metadata': None,
                          'signature_provider_required_options': None},
                         {'is_required': 'false',
                          'priority': '1',
                          'signature_provider_display_name': 'GlobalSign - '
                                                             'Digital Signing '
                                                             'Service (DSS) - '
                                                             'Production',
                          'signature_provider_id': '73',
                          'signature_provider_name': 'globalsign_tsp',
                          'signature_provider_options_metadata': None,
                          'signature_provider_required_options': None}]}

If I try to print provider[0], I get a TypeError: 'AccountSignatureProviders' object is not subscriptable. So I can't pass that to the Signer object.

How do I choose a signature provider to use when passing the accounts_api object to the Signers object?


Solution

  • providers.to_dict() converts the AccountSignatureProviders object to a dictionary at which point you can iterate through the signature providers via json.dumps(providers['signature_providers'][1]).

    There is another option provided by this documentation for the AccountSignatureProviders object. You can index the providers with AccountSignatureProviders.signature_providers[x]

    From here you can set the signature provider to the Signer object by putting the indexed provider in a list to provide to the recipient_signature_providers parameter: recipient_signature_providers=[AccountSignatureProviders.signature_providers[x]].