|
1 | | -# Multiple DocuSign Signature REST API recipes in Python |
| 1 | +# Python: Authorization Code Grant Examples |
2 | 2 |
|
3 | | -Repo: esignature-recipes-python |
| 3 | +### Github repo: eg-03-python-auth-code-grant |
| 4 | +## Introduction |
| 5 | +This repo is a Python 3 application that demonstrates: |
4 | 6 |
|
5 | | -This is a **beta** release. Comments are welcomed. |
| 7 | +* Authentication with DocuSign via the |
| 8 | +[Authorization Code Grant flow](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-code-grant). |
| 9 | +When the token expires, the user is asked to re-authenticate. |
| 10 | +The **refresh token** is not used in this example. |
| 11 | +1. **Embedded Signing Ceremony.** |
| 12 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg001_embedded_signing.py) |
| 13 | + This example sends an envelope, and then uses an embedded signing ceremony for the first signer. |
| 14 | + With embedded signing, the DocuSign signing ceremony is initiated from your website. |
| 15 | +1. **Send an envelope with a remote (email) signer and cc recipient.** |
| 16 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg002_signing_via_email.py) |
| 17 | + The envelope includes a pdf, Word, and HTML document. |
| 18 | + Anchor text ([AutoPlace](https://support.docusign.com/en/guides/AutoPlace-New-DocuSign-Experience)) is used to position the signing fields in the documents. |
| 19 | +1. **List envelopes in the user's account.** |
| 20 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg003_list_envelopes.py) |
| 21 | + The envelopes' current status is included. |
| 22 | +1. **Get an envelope's basic information.** |
| 23 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg004_envelope_info.py) |
| 24 | + The example lists the basic information about an envelope, including its overall status. |
| 25 | +1. **List an envelope's recipients** |
| 26 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg005_envelope_recipients.py) |
| 27 | + Includes current recipient status. |
| 28 | +1. **List an envelope's documents.** |
| 29 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg006_envelope_docs.py) |
| 30 | +1. **Download an envelope's documents.** |
| 31 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg007_envelope_get_doc.py) |
| 32 | + The example can download individual |
| 33 | + documents, the documents concatenated together, or a zip file of the documents. |
| 34 | +1. **Programmatically create a template.** |
| 35 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg008_create_template.py) |
| 36 | +1. **Send an envelope using a template.** |
| 37 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg009_use_template.py) |
| 38 | +1. **Send an envelope and upload its documents with multpart binary transfer.** |
| 39 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg010_send_binary_docs.py) |
| 40 | + Binary transfer is 33% more efficient than using Base64 encoding. |
| 41 | +1. **Embedded sending.** |
| 42 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg011_embedded_sending.py) |
| 43 | + Embeds the DocuSign web tool (NDSE) in your web app to finalize or update |
| 44 | + the envelope and documents before they are sent. |
| 45 | +1. **Embedded DocuSign web tool (NDSE).** |
| 46 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg012_embedded_console.py) |
| 47 | +1. **Embedded Signing Ceremony from a template with an added document.** |
| 48 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg013_add_doc_to_template.py) |
| 49 | + This example sends an envelope based on a template. |
| 50 | + In addition to the template's document(s), the example adds an |
| 51 | + additional document to the envelope by using the |
| 52 | + [Composite Templates](https://developers.docusign.com/esign-rest-api/guides/features/templates#composite-templates) |
| 53 | + feature. |
| 54 | +1. **Payments example: an order form, with online payment by credit card.** |
| 55 | + [Source.](https://github.com/docusign/eg-03-node-auth-code-grant/blob/master/app/eg014_collect_payment.py) |
6 | 56 |
|
7 | | -This repo contains a Python Flask application that demonstrates several of the |
8 | | -DocuSign Signature REST API recipes: |
| 57 | +## Installation |
9 | 58 |
|
10 | | -* Embedded signing. See app/py_001_embedded_signing |
11 | | -* Sending a signature request via email. See app/py_004_email_send |
12 | | -* Sending a signature request using a template. See app/py_002_email_send_template |
13 | | -* Get envelopes’ statuses. See app/py_005_envelope_list_status |
14 | | -* Get an envelope’s status. See app/py_006_envelope_status |
15 | | -* Get an envelope’s recipient statuses. See app/py_007_envelope_recipient_status |
16 | | -* Using a webhook to receive status changes. See app/lib_master_python/ds_webhook.py |
17 | | -* Authenticating with the Signature REST API. See app/lib_master_python/ds_authentication.py |
18 | | -* Embedded tagging and sending of an envelope. See app/py_012_embedded_tagging |
| 59 | +### Prerequisites |
| 60 | +1. A DocuSign Developer Sandbox account (email and password) on [demo.docusign.net](https://demo.docusign.net). |
| 61 | + Create a [free account](https://go.docusign.com/o/sandbox/). |
| 62 | +1. A DocuSign Integration Key (a client ID) that is configured to use the |
| 63 | + OAuth Authorization Code flow. |
| 64 | + You will need the **Integration Key** itself, and its **secret**. |
19 | 65 |
|
20 | | -## API Logging Feature |
21 | | -The application also enables you to easily view your account’s API logs. It shows all API requests to your |
22 | | -demo account, from this application, and from others including the DocuSign web tool. |
| 66 | + If you use this example on your own workstation, |
| 67 | + the Integration key must include a **Redirect URI** of `http://localhost:5000/ds/callback` |
23 | 68 |
|
24 | | -## Try it on Heroku |
25 | | -Use the deploy button to immediately try this app on Heroku. You can use Heroku’s free service tier, no credit card is needed. |
| 69 | + If you will not be running the example on your own workstation, |
| 70 | + use the appropriate DNS name and port instead of `localhost` |
26 | 71 |
|
27 | | -[](https://heroku.com/deploy) |
| 72 | +1. Python 3. |
| 73 | +1. A name and email for a signer, and a name and email for a cc recipient. |
28 | 74 |
|
29 | | -### Integration Key and Secret |
30 | | -**Do not use** the DS_OAUTH_CLIENT_ID or DS_OAUTH_SECRET config variables. |
| 75 | +### Installation steps |
| 76 | +1. Download or clone this repository to your workstation to directory **eg-03-python-auth-code-grant** |
| 77 | +1. **cd eg-03-python-auth-code-grant** |
| 78 | +1. **pip3 install -r requirements.txt** (or pipenv can be used) |
| 79 | +1. Update the file **app/ds_config.py** |
| 80 | + with the Integration Key and other settings. |
31 | 81 |
|
32 | | -Instead, enter your Integration Key (Client ID) and Secret after you have started the software on Heroku. |
| 82 | + **Note:** Protect your Integration Key and secret--you |
| 83 | + should ensure that ds_config.py file will not be stored in your source code |
| 84 | + repository. |
33 | 85 |
|
34 | | -Details: the config variables should only be used if the new server's name is already known and has been |
35 | | -registered as a redirect URI with the DocuSign authentication service. |
| 86 | +1. **python3 run.py** |
| 87 | +1. Open a browser to **http://localhost:5000** |
36 | 88 |
|
37 | | -### Build delays |
38 | | -Note: during the Heroku *build* process, the setup.py step for **lxml** takes several minutes since it includes a compilation. |
| 89 | +#### Payments code example |
| 90 | +To use the payments example, create a |
| 91 | +test payments gateway for your developer sandbox account. |
39 | 92 |
|
40 | | -## Run the app locally |
| 93 | +See the |
| 94 | +[PAYMENTS_INSTALLATION.md](https://github.com/docusign/eg-03-python-auth-code-grant/blob/master/PAYMENTS_INSTALLATION.md) |
| 95 | +file for instructions. |
41 | 96 |
|
42 | | -1. Install a recent version of Python 2.x, eg 2.7.11 or later. |
43 | | -1. Install pip |
44 | | -1. Clone this repo to your computer |
45 | | -1. `cd` to the repo’s directory |
46 | | -1. `pip install -r requirements.txt` # installs the application’s requirements |
47 | | -1. `python run.py` # starts the application on port 5000 |
48 | | -1. Use a browser to load [http://127.0.0.1:5000/](http://127.0.0.1:5000/) |
| 97 | +Then add the payment gateway account id to the **app/ds_config.py** file. |
49 | 98 |
|
50 | | -## Have a question? Pull request? |
51 | | -If you have a question about the Signature REST API, please use StackOverflow and tag your question with `docusignapi` |
| 99 | +## Using the examples with other authentication flows |
52 | 100 |
|
53 | | -For bug reports and pull requests, please use this repo’s issues page. |
| 101 | +The examples in this repository can also be used with either the |
| 102 | +Implicit Grant or JWT OAuth flows. |
| 103 | +See the [Authentication guide](https://developers.docusign.com/esign-rest-api/guides/authentication) |
| 104 | +for information on choosing the right authentication flow for your application. |
| 105 | + |
| 106 | +## License and additional information |
| 107 | + |
| 108 | +### License |
| 109 | +This repository uses the MIT License. See the LICENSE file for more information. |
| 110 | + |
| 111 | +### Pull Requests |
| 112 | +Pull requests are welcomed. Pull requests will only be considered if their content |
| 113 | +uses the MIT License. |
0 commit comments