Java: Authorization Code Grant Examples
Github repo: eg-03-java-auth-code-grant
This repo is a Java Spring Boot application that demonstrates:
- Authentication with DocuSign via the Authorization Code Grant flow. The Spring Security library is used.
- Embedded Signing Ceremony. Source. This example sends an envelope, and then uses an embedded signing ceremony for the first signer. With embedded signing, the DocuSign signing ceremony is initiated from your website.
- Send an envelope with a remote (email) signer and cc recipient. Source. The envelope includes a pdf, Word, and HTML document. Anchor text (AutoPlace) is used to position the signing fields in the documents.
- List envelopes in the user's account. Source.
- Get an envelope's basic information. Source. The example lists the basic information about an envelope, including its overall status.
- List an envelope's recipients and their current status. Source.
- List an envelope's documents. Source.
- Download an envelope's documents. The example can download individual documents, the documents concatenated together, or a zip file of the documents. Source.
- Programmatically create a template. Source.
- Send an envelope using a template. Source.
- Send an envelope and upload its documents with multipart binary transfer. Source. Binary transfer is 33% more efficient than using Base64 encoding.
- Embedded sending. Source.
- Embedded DocuSign web tool (NDSE). Source.
- Embedded Signing Ceremony from a template with an added document. Source. This example sends an envelope based on a template. In addition to the template's document(s), the example adds an additional document to the envelope by using the Composite Templates feature.
- Payments example: an order form, with online payment by credit card. Source.
- Get the envelope tab data. (Coming soon...)
- Set envelope tab values. (Coming soon...)
- Set template tab values. (Coming soon...)
- Get the envelope custom field data (metadata). (Coming soon...)
- Requiring an Access Code for a Recipient Source. This example sends and envelope that requires an access-code for the purpose of multi-factor authentication.
- Requiring SMS authentication for a recipient Source. This example sends and envelope that requires entering in a six digit code from an text message for the purpose of multi-factor authentication.
- Requiring Phone authentication for a recipient Source. This example sends and envelope that requires entering in a voice-based response code for the purpose of multi-factor authentication.
- Requiring Knowledge-Based Authentication (KBA) for a Recipient Source. This example sends and envelope that requires passing a Public records check to validate identity for the purpose of multi-factor authentication.
A DocuSign Integration Key (a client ID) that is configured to use the OAuth Authorization Code flow. You will need the Integration Key itself, and its secret.
If you use this example on your own workstation, the Integration key must include a Redirect URI of
If you will not be running the example on your own workstation, use the appropriate DNS name and port instead of
localhost:8080. An example Redirect URI: http://myserver.it.mycompany.com/login
Java 8 or later.
A name and email for a signer, and a name and email for a cc recipient. The signer and the cc email cannot be the same.
Short installation instructions
- Download or clone this repository.
- The project includes a Maven pom file.
- Configure the project by updating the file
- The project's main class is
- Note that IntelliJ Community Edition does not directly support Spring Boot applications.
IntelliJ Ultimate installation
See the IntelliJ Ultimate instructions.
Configure the example
Configure the example via the properties file:
Add the client id, secret, signer name and email to the file. Also add the URL that the application will use (the DS_APP_URL setting). By default, this is http://localhost:8080
You must also add a Redirect URI to the client id's settings in
DocuSign. The Redirect URI is
/login appended to the DS_APP_URL setting.
You should add
application.properties to your .gitignore file so your
private information will not be added to your repository.
Do not store your client id (Integration Key), secret, or other
private information in your code repository.
Payments code example
To use the payments example, create a test payments gateway for your developer sandbox account.
See the PAYMENTS_INSTALLATION.md file for instructions.
Then add the payment gateway account id to the application.properties file.
Using the examples with other authentication flows
The examples in this repository can also be used with the JWT OAuth flow. See the Authentication guide for information on choosing the right authentication flow for your application.
License and additional information
This repository uses the MIT License. See the LICENSE file for more information.
Pull requests are welcomed. Pull requests will only be considered if their content uses the MIT License.