Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy Issues #152

Closed
hanlyyn opened this issue Jul 2, 2020 · 6 comments
Closed

Proxy Issues #152

hanlyyn opened this issue Jul 2, 2020 · 6 comments

Comments

@hanlyyn
Copy link

hanlyyn commented Jul 2, 2020

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?

@LarryKlugerDS
Copy link
Contributor

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.

@hanlyyn
Copy link
Author

hanlyyn commented Jul 6, 2020

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.

@LarryKlugerDS
Copy link
Contributor

Hi @hanlyyn , thank you for your suggestion. I have filed enhancement request DCM-4358.

@psytester
Copy link
Contributor

Looks like this enhancement could do the final job for #73 too

@loopforever
Copy link

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.

@mmallis87
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants