docusign / docusign-esign-java-client

The Official Docusign Java Client Library used to interact with the eSignature REST API. Send, sign, and approve documents using this client.
https://javadoc.io/doc/com.docusign/docusign-esign-java/latest/index.html
MIT License
105 stars 96 forks source link

NullPointer in AuthenticationApi.login #138

Closed dcestnik closed 4 years ago

dcestnik commented 4 years ago

In versions >= 2.10.0 any call to the method AuthenticationApi.login will fail with a null pointer exception. Applying the below patch to eg-01-java-jwt will reproduce the issue. I believe it is caused by this which was introduced in 2.10.0. Please advise if there is a work around. We are needing to call this method in order to fetch the login accounts baseUrl in our application.

diff --git a/src/main/java/com/docusign/example/jwt/JWTExample.java b/src/main/java/com/docusign/example/jwt/JWTExample.java
index 6a81044..a4aece7 100644
--- a/src/main/java/com/docusign/example/jwt/JWTExample.java
+++ b/src/main/java/com/docusign/example/jwt/JWTExample.java
@@ -1,11 +1,12 @@
 package com.docusign.example.jwt;

+import com.docusign.esign.api.AuthenticationApi;
 import com.docusign.esign.client.ApiClient;
 import com.docusign.esign.client.ApiException;
 import com.docusign.esign.model.Envelope;
 import com.docusign.esign.model.EnvelopeSummary;
 import com.docusign.esign.model.EnvelopesInformation;
-import com.docusign.esign.model.Recipients;
+import com.docusign.esign.model.LoginInformation;

 import java.io.IOException;
 import java.util.Arrays;
@@ -20,6 +21,9 @@ public class JWTExample {
     public static void main(String args[]) {
         try {
             System.setProperty("https.protocols","TLSv1.2");
+            AuthenticationApi authenticationApi = new AuthenticationApi(apiClient);
+            authenticationApi.login(); // This will trigger NPE due to ApiClient setting OAuthClient to null in its constructor.
+
             System.out.println("\nSending an envelope. The envelope includes HTML, Word, and PDF documents. It takes about 15 seconds for DocuSign to process the envelope request... ");
             EnvelopeSummary result = new SendEnvelope(apiClient).sendEnvelope();
             System.out.println(
mmallis87 commented 4 years ago

@dcestnik Authentication class is deprecated (although we need to document this fact better). Please use ApiClient.getUserInfo instead to get the list of accounts like in the JWT example: https://github.com/docusign/eg-01-java-jwt/blob/master/src/main/java/com/docusign/example/jwt/ExampleBase.java#L71

dcestnik commented 4 years ago

@mmallis87 thanks for the info

mmallis87 commented 4 years ago

You're welcome sir!