You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-20Lines changed: 38 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,10 @@
1
-
# Python: Authorization Code Grant Examples
1
+
# Python Launcher Code Examples
2
2
3
-
### Github repo: eg-03-python-auth-code-grant
3
+
### Github repo: [code-examples-python](./)
4
4
## Introduction
5
5
This repo is a Python 3 application that demonstrates:
6
6
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
-
* Authentication with DocuSign via the [JSON Web Token (JWT) Grant](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-jsonwebtoken).
This example sends an envelope, and then uses an embedded signing ceremony for the first signer.
@@ -119,14 +114,23 @@ When the token expires, it updates automatically.
119
114
Firstly, creates a bulk send recipients list, and then creates an envelope.
120
115
After that, initiates bulk envelope sending.
121
116
117
+
118
+
## Included OAuth grant types:
119
+
120
+
* Authentication with Docusign via [Authorization Code Grant flow](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-code-grant) .
121
+
When the token expires, the user is asked to re-authenticate.
122
+
The **refresh token** is not used in this example.
123
+
124
+
* Authentication with DocuSign via the [JSON Web Token (JWT) Grant](https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-jsonwebtoken).
125
+
When the token expires, it updates automatically.
126
+
127
+
122
128
## Installation
123
129
124
130
### Prerequisites
125
131
1. A DocuSign Developer Sandbox account (email and password) on [demo.docusign.net](https://demo.docusign.net).
126
132
Create a [free account](https://go.docusign.com/sandbox/productshot/?elqCampaignId=16535).
127
-
1. A DocuSign Integration Key (a client ID) that is configured to use the
128
-
OAuth Authorization Code flow.
129
-
You will need the **Integration Key** itself, and its **secret**.
133
+
1. A DocuSign Integration Key (a client ID). To use Authorization code grant, you will need the **Integration Key** itself, and its **secret**. To use JSON Web token, you will need the **Integration Key** itself, the **RSA Secret Key** and an API user ID for the user you are impersonating.
130
134
131
135
If you use this example on your own workstation,
132
136
the Integration key must include a **Redirect URI** of `http://localhost:5000/ds/callback`
@@ -147,16 +151,28 @@ When the token expires, it updates automatically.
147
151
1. Download or clone this repository to your workstation to directory **eg-03-python-auth-code-grant**
148
152
1.**cd eg-03-python-auth-code-grant**
149
153
1.**pip3 install -r requirements.txt** (or pipenv can be used)
150
-
1. Update the file **app/ds_config.py**
151
-
with the Integration Key and other settings.
154
+
1. Make a copy of the **app/ds_config_sample.py** and name it **ds_config.py**
155
+
1. Update this new file **app/ds_config.py**
156
+
with your Integration Key and other settings.
152
157
153
158
**Note:** Protect your Integration Key and secret--you
154
159
should ensure that ds_config.py file will not be stored in your source code
155
160
repository.
156
161
157
-
1.**python3 run.py**
162
+
1.**python run.py**
158
163
1. Open a browser to **http://localhost:5000**
159
164
165
+
### Configuring JWT
166
+
167
+
1. Create a developer sandbox account on developers.docusign.com if you don't already have one.
168
+
2. Create a new API key in the Admin panel: https://admindemo.docusign.com/api-integrator-key, take note of the public key.
169
+
3. Set a redirect URI of `http://localhost:5000/ds/callback` as mentioned in the installation steps above for the API key you make in step 2.
170
+
4. Generate an RSA keypair in the administrator console on the DocuSign developer sandbox and copy the private key to a secure location.
171
+
5. Create a new file in your repo source folder named **private.key**, and paste in that copied RSA private key, then save it.
172
+
6. Update the file **app/ds_config.py** and include the newly created API key from step 2 as well as your account user id GUID which is also found on the Admin panel: `https://admindemo.docusign.com/api-integrator-key`.
173
+
174
+
From there you should be able to run the launcher using **python run.py** then selecting **JSON Web Token** when authenticaing your account.
175
+
160
176
#### Payments code example
161
177
To use the payments example, create a
162
178
test payments gateway for your developer sandbox account.
@@ -167,18 +183,20 @@ file for instructions.
167
183
168
184
Then add the payment gateway account id to the **app/ds_config.py** file.
169
185
170
-
## Using the examples with other authentication flows
171
186
172
-
The examples in this repository can also be used with either the
173
-
Implicit Grant or JWT OAuth flows.
174
-
See the [Authentication guide](https://developers.docusign.com/esign-rest-api/guides/authentication)
175
-
for information on choosing the right authentication flow for your application.
176
187
177
188
## License and additional information
178
189
190
+
### Implicit Grant
191
+
192
+
The examples in this repository can also be used with the
193
+
Implicit Grant OAuth flow.
194
+
See the [Authentication guide](https://developers.docusign.com/esign-rest-api/guides/authentication)
195
+
for information on choosing the right authentication flow for your application.
196
+
179
197
### License
180
198
This repository uses the MIT License. See the LICENSE file for more information.
181
199
182
200
### Pull Requests
183
201
Pull requests are welcomed. Pull requests will only be considered if their content
"allow_silent_authentication": True, # a user can be silently authenticated if they have an
15
15
# active login session on another tab of the same browser
@@ -29,7 +29,7 @@
29
29
30
30
DS_JWT= {
31
31
"ds_client_id": "{CLIENT_ID}",
32
-
"ds_impersonated_user_id": "{IMPERSONATED_USER_ID}", # the id of the user
33
-
"private_key_file": "private.key", # path to file which hold private key or private key itself
34
-
"authorization_server": "account-d.docusign.com",
32
+
"ds_impersonated_user_id": "{IMPERSONATED_USER_ID}", # The id of the user.
33
+
"private_key_file": "./private.key", # Create a new file in your repo source folder named private.key then copy and paste your RSA private key there and save it.
0 commit comments