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;
}