Skip to main content
Question

Error obtaining token

  • 19 August 2024
  • 2 replies
  • 25 views

Hi everyone, I'm having trouble obtaining the authentication token within a REST service I'm creating. Below is the error log.

 

ago. 19, 2024 9:17:56 AM org.apache.catalina.core.StandardWrapperValve invoke

SEVERE: Servlet.service() for servlet default] in context with path [/teste-restfull] threw exception Error processing webservice request] with root cause

com.docusign.esign.client.ApiException: Error while requesting an access token: ResponseImpl{status=200}

at com.docusign.esign.client.ApiClient.requestJWTUserToken(ApiClient.java:913)

 


@Path("/hello")

public class TestService {

 

@Context

private HttpServletRequest request;

 

@GET

@Produces(MediaType.TEXT_PLAIN)

public String index() throws ApiException, IOException {

 

File appConfig = Paths.getUri("app.config").toFile();

File privateKey = Paths.getUri("private.key").toFile();

 

FileInputStream fisAConfig = new FileInputStream(appConfig);

FileInputStream fisPKey = new FileInputStream(privateKey);

 

Properties prop = new Properties();

prop.load(fisAConfig);

 

ApiClient apiClient = new ApiClient(ApiClient.DEMO_REST_BASEPATH);

apiClient.setOAuthBasePath("account-d.docusign.com");

apiClient.setDebugging(true);

 

ArrayList<String> scopes = new ArrayList<String>();

scopes.add("signature");

scopes.add("impersonation");

 

OAuthToken oAuthToken = apiClient.requestJWTUserToken(prop.getProperty("clientId"), prop.getProperty("userId"), scopes, fisPKey.readAllBytes(), 3600);

String accessToken = oAuthToken.getAccessToken();

 

fisPKey.close();

return accessToken;

}

Hello,

Thank you for reaching out here in the DocuSign Community.

I am very sorry for the inconvenience you are having, however, this error is something generic that can result in several discrepancies within the code, as a recommendation you can use our Quickstart with our SDKs so that once you configure them, this way you can get the complete example of how to send envelopes and obtain the access token.

 

Regards,

Eric | Docusign


Hi Eric,

The problem I'm facing is obtaining the token using an architecture with TomEE 9.1 + Jakarta REST. I used the QuickStart as an example, but I noticed that you use a custom Spring Boot, and my client didn't allow me to use Spring Boot. Have you ever done any integration with REST services calling the DocuSign API? I'm wondering if it's possible to use this API within web services.

Thank you for your help, Eric!


Reply