Closed hanlyyn closed 4 years ago
Hi @hanlyyn , as requested by other developers, we purposefully used the default system properties for setting the proxy so that the SDK would automatically pick up the proxy settings if they're configured.
Since the SDK is open source, you can investigate setting the properties via the APIClient object.
The EnvelopesApi will accept the ApiClient inside the SDK only. So I may have to take out and modify the ApiClient and the EnvelopesApi class from the SDK to make it work.
Can you maybe think of exposing an Interface with the buildHttpClient method inside it so that you can keep your default implementation on your ApiClient by implementing that interface and I can have my own implementation of ApiClient without taking out and modifying the classes from the SDK.
It will make the SDK more generic and customizable in the network layer.
If you can consider this as a feature request its helpful. Because exposing the ApiClient interface can add many more customization in the network layer than just the proxy.
Hi @hanlyyn , thank you for your suggestion. I have filed enhancement request DCM-4358.
Looks like this enhancement could do the final job for #73 too
Just hopping on this ticket to add my vote for support of per-ApiClient proxy settings. The adoption of Java global system properties for this purpose is not ideal. Not all the network connections in my application use the proxy; in fact...none use the proxy except for those destined for the Docusign API.
FYI you can achieve this by extending ApiClient and passing the child class to API classess (e.g. EnvelopesApi class) like this:
class CustomApiClient extends ApiClient {
private CustomApiClient(String basePath) {
super(basePath);
// your customization code goes here
}
}
try {
CustomApiClient customApiClient = new CustomApiClient(BaseUrl);
List<String> scopes = new ArrayList<>();
scopes.add(OAuth.Scope_SIGNATURE);
OAuth.OAuthToken oAuthToken = customApiClient.requestJWTUserToken(IntegratorKey, UserId, scopes, privateKeyBytes, 3600);
customApiClient.setAccessToken(oAuthToken.getAccessToken(), oAuthToken.getExpiresIn());
EnvelopesApi envelopesApi = new EnvelopesApi(customApiClient);
EnvelopeDocumentsResult docsList = envelopesApi.listDocuments(AccountId, envelopeIds[0]);
Assert.assertNotNull(docsList);
Assert.assertEquals(envelopeIds[0], docsList.getEnvelopeId());
System.out.println("EnvelopeDocumentsResult: " + docsList);
} catch (ApiException ex) {
Assert.fail("Exception: " + ex);
} catch (Exception e) {
Assert.fail("Exception: " + e.getLocalizedMessage());
}
To make the docusign-java-client to make the call through an Authenticated proxy, as per the ApiClient, below are the properties we have to set (let me know if I am wrong)
System.getProperty("https.proxyHost") System.getProperty("https.proxyPort") System.getProperty("https.proxyUser") System.getProperty("https.proxyPassword")
My problem is that since the configuration key names are the default names for setting proxies, if I configure these keys, it will affect other library's network calls.
Basically I am looking for flexibility to configure different proxies for my different integrations and if I use the above configuration keys, it kind of stays as default for the entire application.
How can I configure a proxy only for docusign?
Is there a way I can set my own custom-defined ApiClient?
A new interface over ApiClient so that I can implement that and write my own custom ApiClient and set that as my Default ApiClient?