Skip to content
master
Go to file
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Java Launcher Code Examples

Github repo: https://github.com/docusign/code-examples-java

This GitHub repo includes code example for the DocuSign eSignature REST API, for the DocuSign Rooms API and for the Click API.

To use the Rooms API code examples, modify the DS_API_NAME setting at the end of the application.json file. Set the value to ROOMS. To use the Click API code examples, modify the DS_API_NAME setting at the end of the application.json file. Set the value to CLICK.

Note: to use the Rooms API you must also create your DocuSign Developer Account for Rooms.

Java Quickstart video

Introduction

This repo is a Java Spring Boot application that demonstrates how to authenticate with DocuSign via the Authorization Code Grant flow. When the token expires, the user is asked to reauthenticate. The refresh token is not used.

The Spring Boot security Oauth2 boot autoconfigure package is used for authentication.

The OAuth library is used in the file WebSecurityConfig.java.

eSignature API

For more information about the scopes used for obtaining authorization to use the eSignature API, see the Required Scopes section.

  1. Use embedded signing. Source. This example sends an envelope, and then uses embedded signing for the first signer. With embedded signing, DocuSign signing is initiated from your website.

  2. Request a signature by email (Remote Signing). Source. The envelope includes a pdf, Word, and HTML document. Anchor text (AutoPlace) is used to position the signing fields in the documents.

  3. List envelopes in the user's account. Source.

  4. Get an envelope's basic information. Source. The example lists the basic information about an envelope, including its overall status.

  5. List an envelope's recipients and their current status. Source.

  6. List an envelope's documents. Source.

  7. Download an envelope's documents. The example can download individual documents, the documents concatenated together, or a zip file of the documents. Source.

  8. Programmatically create a template. Source.

  9. Request a signature by email using a template. Source.

  10. Send an envelope and upload its documents with multipart binary transfer. Source. Binary transfer is 33% more efficient than using Base64 encoding.

  11. Use embedded sending. Source.

  12. Embedded DocuSign web tool (NDSE). Source.

  13. Use embedded signing 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.

  14. Payments example: an order form, with online payment by credit card. Source.

  15. Get the envelope tab data. Retrieve the tab (field) values for all of the envelope's recipients. Source.

  16. Set envelope tab values. The example creates an envelope and sets the initial values for its tabs (fields). Some of the tabs are set to be read-only, others can be updated by the recipient. The example also stores metadata with the envelope. Source.

  17. Set template tab values. The example creates an envelope using a template and sets the initial values for its tabs (fields). The example also stores metadata with the envelope. Source.

  18. Get the envelope custom field data (metadata). The example retrieves the custom metadata (custom data fields) stored with the envelope. Source.

  19. 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.

  20. 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.

  21. 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.

  22. 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.

  23. Requiring ID Verification (IDV) for a recipient Source. This example sends and envelope that requires the recipient to upload a government issued id.

  24. Creating a permission profile Source. This code example demonstrates how to create a user group's permission profile using the Create Profile method.

  25. Setting a permission profile Source. This code example demonstrates how to set a user group's permission profile using the Update Group method. You must have already created permissions profile and group of users.

  26. Updating individual permission settings Source. This code example demonstrates how to update individual settings for a specific permission profile using the Update Permission Profile method. You must have already created permissions profile and group of users.

  27. Deleting a permission profile Source. This code example demonstrates how to an account's permission profile using the Delete AccountPermissionProfiles method.

  28. Creating a brand Source. This example creates brand profile for an account using the Create Brand method.

  29. Applying a brand to an envelope Source. This code example demonstrates how to apply a brand you've created to an envelope using the Create Envelope method. First, creates the envelope and then applies brand to it. Anchor text (AutoPlace) is used to position the signing fields in the documents.

  30. Applying a brand to a template Source. This code example demonstrates how to apply a brand you've created to a template using using the Create Envelope method. You must have at least one created template and brand.

  31. Bulk sending envelopes to multiple recipients Source. This example creates and sends a bulk envelope by generating a bulk recipient list and initiating a bulk send.

  32. Pausing a signature workflow Source. Source. This code example demonstrates how to create an envelope where the workflow is paused before the envelope is sent to a second recipient.

  33. Unpausing a signature workflow Source. This code example demonstrates how to resume an envelope workflow that has been paused

  34. Using conditional recipients Source. This code example demonstrates how to create an envelope where the workflow is routed to different recipients based on the value of a transaction.

  35. Сreating an envelope where the workflow is paused Source. This code example demonstrates how to create an envelope where the workflow is paused before the envelope is sent to a second recipient.

  36. Resuming an envelope workflow that has been paused Source. This code example demonstrates how to resume an envelope workflow that has been paused.

  37. Use conditional recipients Source. This code example demonstrates how to create an envelope where the workflow is paused before the envelope is sent to a second recipient.

Rooms API

For more information about the scopes used for obtaining authorization to use the Rooms API, see the Required Scopes section.

Note: To use the Rooms API you must also create your DocuSign Developer Account for Rooms. Examples 4 and 6 require that you have the DocuSign Forms feature enabled in your Rooms for Real Estate account.

  1. Create room with Data. Source. This code example creates a new room in your DocuSign Rooms account to be used for a transaction.
  2. Create a room from a template. Source. This code example creates a new room using a template.
  3. Create room with Data. Source. This code example exports all the avialalble data from a specific room in your DocuSign Rooms account.
  4. Add forms to a room. Source. This code example adds a standard real estate related form to a specific room in your DocuSign Rooms account.
  5. How to search for rooms with filters. Source. This code example searches for rooms in your DocuSign Rooms account using a specific filter.
  6. Create an external form fillable session. Source. This code example create an external form that can be filled using DocuSign for a specific room in your DocuSign Rooms account. This example create an external form that can be filled using DocuSign for a specific room in your DocuSign Rooms account.

Click API

For more information about the scopes used for obtaining authorization to use the Click API, see the Required Scopes section

  1. Create Clickwraps. Source. This code example shows how to create a clickwrap.
  2. Activate Clickwrap. Source. This code example shows how to activate a new clickwrap that you have already created.
  3. Clickwrap Versioning. Source. This code example shows how to create a new clickwrap version.
  4. Get a list of Clickwraps. Source. This code example shows how to get a list of clickwraps.
  5. Get Clickwrap Responses. Source. This code example shows how to get clickwrap responses.

Included OAuth grant types:

  • Authentication with Docusign via Authorization Code Grant flow . When the token expires, the user is asked to re-authenticate. The refresh token is not used in this example.

  • Authentication with DocuSign via the JSON Web Token (JWT) Grant. When the token expires, it updates automatically.

    Note: Before you can make any API calls using JWT Grant, you must get your user’s consent for your app to impersonate them. To do this, the impersonation scope is added when requesting a JSON Web Token.

Installation

Prerequisites

Note: If you downloaded this code using Quickstart from the DocuSign Developer Center, skip steps 1 and 2 below as they're automatically performed for you.

  1. A DocuSign developer account (email and password) on demo.docusign.net. Create a free account.

  2. 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. 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.

    If you use this launcher on your own workstation, the Integration key must include following Redirect URIs:

    If you will not be running the launcher on your own workstation, use the appropriate DNS name and port instead of localhost:8080. A sample Redirect URI: http://myserver.it.mycompany.com/login

  3. JDK 11 or later

  4. Maven

  5. 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.

Nice to have

  1. Lombok Annotations Processing configured for your IDE

Authorization Code Grant specifics:

You will need the integration key and its secret. The integration key must include a redirect URI of

{app_url}/login&type=acg where {app_url} is the URL you have associated with the folder where the source files are located. For example, if you have created a web server that enables the URL

http://localhost:8080/

to execute files on the /public folder of this example, then you must add a redirect URI to your integration key with the value http://localhost:8080/login&type=acg

JWT (JSON Web Token) specifics:

You will need the integration key, an RSA private key, and the user ID (GUID) of the impersonated user. The private part of the RSA key pair must be copied over and stored in a private.key file located in src\main\resources\private.key.

Note: Before you can make any API calls using JWT Grant, you must get your user’s consent for your app to impersonate them. To do this, the impersonation scope is added when requesting a JSON Web Token.

Installation steps

  1. Download or clone this repository.
  2. The project includes a Maven pom file.

Note: If you downloaded this code using Quickstart from the DocuSign Developer Center, skip the next step as it was automatically performed for you.

  1. Configure the project by overriding necessary properties from the src\main\resources\application.example.json and saving this file as application.json file. Don't add this file into the Git index.
  2. Add VM argument -Dspring.profiles.active=dev to your IDE
  3. Note that IntelliJ IDEA Community Edition does not directly support Spring Boot applications.
  4. [Optional] Install Lombok for your IDE (See the IntelliJ or Eclipse instructions below for specific details).

Build and run

Launchers are built as a dedicated application with embedded TomCat server. Build:

$ cd code-examples-java
$ mvn package

Run:

$ cd target
$ java -Dspring.profiles.active=dev -jar code-examples-java-1.0-SNAPSHOT.war

IntelliJ Ultimate instructions for Windows

The IntelliJ IDE Ultimate edition can be used with the launcher. The IntelliJ Ultimate edition is required due to its support for Spring Boot and JSP view pages.

Note: If you downloaded this code using Quickstart from the DocuSign Developer Center, skip Step 1 as it was automatically performed for you.

Step 1. Download or clone the code-examples-java repository

Step 2. Start IntelliJ Ultimate and choose the Open or Import option.

IntelliJ Import project

Step 3. Use the popup file chooser to select code-examples-java or your unzipped Quickstart directory.

Step 4. The Import Project wizard will open. It's a series of screens. On the first screen, select Import project from external model and Maven.

IntelliJ Import Maven project

Step 5. Click Finish and the project will be displayed in the IDE.

Configuring IntelliJ's Run/Debug Configuration

IntelliJ uses Run/Debug Configuration to manage settings for running the launcher.

Set up a Run/Debug Configuration for the launcher:

Step 1. Use the menu command Run > Edit configurations... to open the configuration manager.

Step 2. Click the + (plus) sign to add a new configuration. The configuration type is Spring Boot. You may need to open the additional templates section of the template chooser.

Step 3. Update the form with the Name of the configuration to code-examples-java and the Main class for the configuration, com.docusign.App Tip: use the ... (ellipses) button next to the field to choose the Main class.

Under Spring Boot select the Enable debug output checkbox.

Select the OK button.

Configure a Run configuration

Running or debugging the launcher

Use a Run menu option to run or debug the launcher.

After the application finishes building, open your browser to http://localhost:8080

[Optional] Installing Lombok

Click File, then Settings. From there select Plugins. Open the Marketplace tab and type Lombok. It should have an author named Michail Plushnikov. Click install then restart IntelliJ.

Eclipse instructions

Note: If you downloaded this code using Quickstart from the DocuSign Developer Center, skip the first step as it was automatically performed for you.

  • Download or clone this repository.
  • Open Eclipse and select import. When the window appears, click the Maven folder, then click Existing Maven Project and choose Next.
  • For the Root directory, Browse for and select this same repo code-examples-java.
  • Once selected, click Finish at the bottom center to save the project link to your eclipse workspace.
  • Next, click the menu item Run->Run Configurations and choose a new Maven configuration to clean and compile with the following:
    • Name the configuration build (If You have downloaded the launcher via Quickstart, skip this step).
    • Put in the following value for your workspace in the Base Directory: ${workspace_loc:/code-examples-java}.
    • Put in the following values into the Goals field: clean package.
  • Click the JRE tab in the Run Configurations menu and make sure your have a Runtime JRE set to jdk-11 or higher.
  • Click apply to save.
  • Finally, create another configuration by again using Run->Run Configurations, choosing Java Application Configuration with the following:
    • Name the configuration run (If You have downloaded the launcher via Quickstart, skip this step).
    • Put in the following value for project: code-examples-java.
    • Put in the following value into the Main class: com.docusign.App.
  • Run the application by using Run dropdown shortcut then choosing build then choosing run. Open your browser to http://localhost:8080
  • [Optional] Install Lombok by downloading the lombok.jar itself to your local machine, open a terminal or command prompt window and install by typing in java -jar lombok.jar then pressing Enter

Payments code example

To use the payments example, create a test payments gateway for your developer account. See the PAYMENTS_INSTALLATION.md file for instructions.

Then add the payment gateway account id to the application.json file.

License and additional information

License

This repository uses the MIT License. See the LICENSE file for more information.

Pull Requests

Pull requests are welcomed. Pull requests will only be considered if their content uses the MIT License.