Skip to content

Commit aaf2fdc

Browse files
authored
Merge pull request #26 from docusign/Python-Readme-Update
Python readme update
2 parents b72ee8c + 0cf0899 commit aaf2fdc

File tree

1 file changed

+60
-146
lines changed

1 file changed

+60
-146
lines changed

README.md

Lines changed: 60 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -8,188 +8,102 @@
88

99
[Documentation about the DocuSign API](https://developers.docusign.com/)
1010

11-
You can sign up for a free [developer sandbox](https://go.docusign.com/sandbox/productshot/?elqCampaignId=16535).
11+
## Requirements
1212

13-
Requirements
14-
============
13+
- Python 2.7 (3.6+ recommended)
14+
- Free [Developer Sandbox](https://go.docusign.com/sandbox/productshot/?elqCampaignId=16531)
1515

16-
Python 2.7 and 3.6+.
16+
## Compatibility
1717

18-
## PYTHONPATH set up
19-
### *nix
20-
- Find the path to site-packages folders, for your python version. Usually it's under "/usr/lib/python2.7" (Unix) or "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7" (Mac)
21-
- export PYTHONPATH = ${PYTHONPATH}:.:/path/to/site-packages
18+
- Python 2.7+
2219

23-
Ideally you want this last line to be executed each time python command is launched. So you have to add it to ~/.bash_profile, ~/.bashrc or ~/.profile.
20+
## Note
2421

25-
### Windows
26-
- Find the path to site-packages folders, for your python version. Usually it's under "C:\Python27".
27-
- Go to your Windows "Control Panel"
28-
- Open "System Settings"
29-
- Under "Advanced" tab, click on the "Environment Variables" button.
30-
- Check if "PYTHONPATH" variable is defined under the "System Variables" section.
31-
- If not defined yet, click on the "New" button and add it. The value of the varibale should be the path to site-packages (something like "C:\Python27").
22+
This open-source SDK is provided for cases where you would like to make additional changes that the SDK does not provide out-of-the-box. If you simply want to use the SDK with any of the examples shown in the [Developer Center](https://developers.docusign.com/esign-rest-api/code-examples), follow the installation instructions below.
3223

24+
## Installation
3325

34-
Now that you've added the site-packages folder, to the list of modules python command scans, when it starts, it time to verify it's working:
35-
- open python command prompt and type "help('modules')". Your should now see the list of modules installed under site-packages.
26+
### Path Setup:
3627

37-
Installation
38-
============
28+
1. Locate your Python installation, also referred to as a **site-packages** folder. This folder is usually labeled in a format of Python{VersionNumber}.
3929

40-
### PyPI Package Index
30+
**Examples:**
4131

42-
Install the client locally: `pip install docusign_esign` (note you may have to use `sudo` based on your permissions)
32+
- **Unix/Linux:** /usr/lib/python2.7
33+
- **Mac:** /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
34+
- **Windows:** C:\Users\{username}\AppData\Local\Programs\Python\Python37
4335

44-
Alternatively you can just copy the source code directly into your project.
36+
1. Add the path to your Python folder as an environment variable.
4537

46-
#### Dependencies
38+
**Unix/Linux:**
4739

48-
This client has the following external dependencies:
49-
50-
* certifi >= 14.05.14
51-
* six == 1.8.0
52-
* python_dateutil >= 2.5.3
53-
* setuptools >= 21.0.0
54-
* urllib3 >= 1.15.1
55-
* jwcrypto >= 0.4.2
56-
* py-oauth2 >= 0.0.10
57-
58-
Usage
59-
=====
60-
61-
To initialize the client, make the Login API Call and send a template for signature:
62-
63-
Run this script using python command
64-
```python
65-
from __future__ import absolute_import, print_function
66-
from pprint import pprint
67-
import unittest
68-
import webbrowser
69-
70-
import docusign_esign as docusign
71-
from docusign_esign import AuthenticationApi, TemplatesApi, EnvelopesApi
72-
from docusign_esign.rest import ApiException
73-
74-
user_name = "[USERNAME]"
75-
integrator_key = "[INTEGRATOR_KEY]"
76-
base_url = "https://demo.docusign.net/restapi"
77-
oauth_base_url = "account-d.docusign.com" # use account.docusign.com for Live/Production
78-
redirect_uri = "https://www.docusign.com/api"
79-
private_key_filename = "keys/docusign_private_key.txt"
80-
user_id = "[USER_ID]"
81-
template_id = "[TEMPLATE_ID]"
82-
83-
api_client = docusign.ApiClient(base_url)
84-
85-
# IMPORTANT NOTE:
86-
# the first time you ask for a JWT access token, you should grant access by making the following call
87-
# get DocuSign OAuth authorization url:
88-
oauth_login_url = api_client.get_jwt_uri(integrator_key, redirect_uri, oauth_base_url)
89-
# open DocuSign OAuth authorization url in the browser, login and grant access
90-
# webbrowser.open_new_tab(oauth_login_url)
91-
print(oauth_login_url)
40+
- Type the following command into your console:
41+
**export PYTHONPATH = "${PYTHONPATH}:.:/path/to/site-packages"**
42+
- Optionally, you can add this command to your system profile, which will run the command each time Python is launched.
9243

93-
# END OF NOTE
44+
**Windows:**
9445

95-
# configure the ApiClient to asynchronously get an access token and store it
96-
api_client.configure_jwt_authorization_flow(private_key_filename, oauth_base_url, integrator_key, user_id, 3600)
46+
<ol>
47+
<li>Open the Windows <b>Control Panel.</b></li>
48+
<li>Under the System and Security category, open the <b>System</b></li>
49+
<li>Select <b>Advanced System Settings</b> to open the <b>System Properties</b> dialog box.</li>
50+
<li>On the <b>Advanced</b> tab, select the <b>Environmental Variables</b> button at the lower-right corner.
51+
<ol style="list-style-type: lower-alpha">
52+
<li>Check if <b>PYTHONPATH</b> has been added as a <b>system variable.</b></li>
53+
<li>If it has not, select <b>New</b> to add it. The variable you add is the path to the <b>site-packages</b></li>
54+
</ol>
55+
</li>
56+
</ol>
9757

98-
docusign.configuration.api_client = api_client
58+
**Note:** If you are still unable to reference python or pip via your command console,you can also add the path to the site-packages folder to the built-in environment variable labeled **Path** , which will take effect the next time you start your machine.
9959

100-
template_role_name = 'Needs to sign'
60+
### Install via PIP:
10161

102-
# create an envelope to be signed
103-
envelope_definition = docusign.EnvelopeDefinition()
104-
envelope_definition.email_subject = 'Please Sign my Python SDK Envelope'
105-
envelope_definition.email_blurb = 'Hello, Please sign my Python SDK Envelope.'
62+
1. In your command console, type:
63+
pip install docusign-esign
10664

107-
# assign template information including ID and role(s)
108-
envelope_definition.template_id = template_id
65+
Note: This may require the command console be elevated. You can accomplish this via sudoin Unix/Linux, or by running the command console as an administrator in Windows.
10966

110-
# create a template role with a valid template_id and role_name and assign signer info
111-
t_role = docusign.TemplateRole()
112-
t_role.role_name = template_role_name
113-
t_role.name ='Pat Developer'
114-
t_role.email = user_name
67+
## Dependencies
11568

116-
# create a list of template roles and add our newly created role
117-
# assign template role(s) to the envelope
118-
envelope_definition.template_roles = [t_role]
119-
120-
# send the envelope by setting |status| to "sent". To save as a draft set to "created"
121-
envelope_definition.status = 'sent'
122-
123-
auth_api = AuthenticationApi()
124-
envelopes_api = EnvelopesApi()
125-
126-
try:
127-
login_info = auth_api.login(api_password='true', include_account_id_guid='true')
128-
assert login_info is not None
129-
assert len(login_info.login_accounts) > 0
130-
login_accounts = login_info.login_accounts
131-
assert login_accounts[0].account_id is not None
132-
133-
base_url, _ = login_accounts[0].base_url.split('/v2')
134-
api_client.host = base_url
135-
docusign.configuration.api_client = api_client
136-
137-
envelope_summary = envelopes_api.create_envelope(login_accounts[0].account_id, envelope_definition=envelope_definition)
138-
assert envelope_summary is not None
139-
assert envelope_summary.envelope_id is not None
140-
assert envelope_summary.status == 'sent'
141-
142-
print("EnvelopeSummary: ", end="")
143-
pprint(envelope_summary)
69+
This client has the following external dependencies:
14470

145-
except ApiException as e:
146-
print("\nException when calling DocuSign API: %s" % e)
147-
assert e is None # make the test case fail in case of an API exception
148-
```
71+
- certifi v14.05.14+
72+
- six v1.8.0
73+
- python\_dateutil v2.5.3+
74+
- setuptools v21.0.0+
75+
- urllib3 v1.15.1+
76+
- jwcrypto v0.4.2+
77+
- py-oauth2 v0.0.10+
14978

150-
See [unit_tests.py](./test/unit_tests.py) for more examples.
79+
## Code Examples
15180

152-
# Authentication
81+
### Launchers
15382

154-
## Service Integrations that use Legacy Header Authentication
83+
DocuSign provides a sample application referred to as a [Launcher](https://github.com/docusign/eg-03-python-auth-code-grant). The Launcher contains a set of 14 common use cases and associated source files. These examples use DocuSign&#39;s [Authorization Code Grant](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-code-grant) flow.
15584

156-
([Legacy Header Authentication](https://docs.docusign.com/esign/guide/authentication/legacy_auth.html) uses the X-DocuSign-Authentication header.)
85+
## Proof-of-concept applications
15786

158-
1. Use the [Authentication: login method](https://docs.docusign.com/esign/restapi/Authentication/Authentication/login/) to retrieve the account number **and the baseUrl** for the account.
159-
The url for the login method is www.docusign.net for production and demo.docusign.net for the developer sandbox.
160-
The `base_url` field is part of the `login_account` object. See the [docs and the login_account object](https://docs.docusign.com/esign/restapi/Authentication/Authentication/login/#/definitions/loginAccount)
161-
2. The base_url for the selected account, in production, will start with na1, na2, na3, eu1, or something else. Use the base_url that is returned to create the *host* (see the next step.) Use the host for all of your subsequent API calls.
162-
3. As returned by login method, the base_url includes the API version and account id. Split the string to obtain the *host*, just the server name and api name. Eg, you will receive `https://na1.docusign.net/restapi/v2/accounts/123123123`. You want just `https://na1.docusign.net/restapi`
163-
4. Instantiate the SDK using the basePath. Eg `api_client = docusign.ApiClient(host)`
164-
5. Set the authentication header as shown in the examples by using `api_client.set_default_header`
87+
If your goal is to create a proof of concept application, DocuSign provides a set of [Quick Start](https://github.com/docusign/qs-python) examples. The Quick Start examples are meant to be used with DocuSign&#39;s [OAuth Token Generator](https://developers.docusign.com/oauth-token-generator), which will allow you to generate tokens for the Demo/Sandbox environment only. These tokens last for eight hours and will enable you to build your proof-of-concept application without the need to fully implement an OAuth solution.
16588

166-
## User Applications that use OAuth Authentication
167-
1. After obtaining a Bearer token, call the [OAuth: Userinfo method](https://docs.docusign.com/esign/guide/authentication/userinfo.html). Obtain the selected account's `base_uri` (server name) field.
168-
The url for the Userinfo method is account-d.docusign.com for the demo/developer environment, and account.docusign.com for the production environment.
169-
1. Combine the base_uri with "/restapi" to create the host. The base_uri will start with na1, na2, na3, eu1, or something else. Use the host for your subsequent API calls.
170-
4. Instantiate the SDK using the basePath. Eg `api_client = docusign.ApiClient(host)`
171-
5. Create the `authentication_value` by combining the `token_type` and `access_token` fields you receive from either an [Authorization Code Grant](https://docs.docusign.com/esign/guide/authentication/oa2_auth_code.html) or [Implicit Grant](https://docs.docusign.com/esign/guide/authentication/oa2_implicit.html) OAuth flow.
172-
5. Set the authentication header by using `api_client.set_default_header('Authorization', authentication_value)`
89+
## OAuth Implementations
17390

174-
Testing
175-
=======
91+
For details regarding which type of OAuth grant will work best for your DocuSign integration, see the [REST API Authentication Overview](https://developers.docusign.com/esign-rest-api/guides/authentication) guide located on the [DocuSign Developer Center](https://developers.docusign.com/esign-rest-api/guides/authentication).
17692

177-
Unit tests are available in the [Test](https://github.com/docusign/docusign-python-client/tree/master/test/unit_tests.py) folder.
93+
For security purposes, DocuSign recommends using the [Authorization Code Grant](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-code-grant) flow.
17894

179-
Contributing
180-
============
95+
There are other use-case scenarios, such as **single-page applications** (SPA) that use **Cross-Origin Resource Sharing** (CORS), or where there may not be a user to interact with your Service Account. For these use cases, DocuSign also supports [JWT](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-jsonwebtoken) and [Implicit](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-implicit) grants. For code examples, see the links below:
18196

182-
**This SDK is auto-generated from OpenAPI specification file. For that reason, we actually do NOT accept pull requests. If you find a bug or have an idea that you want to see in the SDK, please open a new [issue](https://github.com/docusign/docusign-python-client/issues/new).**
97+
- [JWT (JSON Web Token)](https://github.com/docusign/eg-01-python-jwt)
98+
- Implicit Grant (coming soon)
18399

184-
Support
185-
=======
100+
## Support
186101

187-
Feel free to log issues against this client through GitHub. We also have an active developer community on Stack Overflow, search the [DocuSignAPI](http://stackoverflow.com/questions/tagged/docusignapi) tag.
102+
Log issues against this client through GitHub. We also have an [active developer community on Stack Overflow](http://stackoverflow.com/questions/tagged/docusignapi).
188103

189-
License
190-
=======
104+
## License
191105

192-
The DocuSign Node Client is licensed under the following [License](LICENSE).
106+
The DocuSign Python Client is licensed under the [MIT License](https://github.com/docusign/docusign-python-client/blob/master/LICENSE).
193107

194108

195109
[pypi-image]: https://img.shields.io/pypi/v/docusign_esign.svg?style=flat

0 commit comments

Comments
 (0)