Configuring a Proxy Server
  • 10 Oct 2024
  • 3 Minutes to read
  • Dark
    Light
  • PDF

Configuring a Proxy Server

  • Dark
    Light
  • PDF

Article summary

Java SDK.NET SDKREST API

Java SDK

To download the full code sample see our Code Share site.

A proxy server is a server that acts as an intermediary for requests from clients seeking resources from other servers. With OneSpan Sign, you can make API calls via a proxy server.

To make API calls to OneSpan Sign using a proxy server, you will need to build a ProxyConfiguration object. You will need to pass the proxy server's address and port number to the withHttpHost() and withHttpPort() methods respectively.

ProxyConfiguration httpProxyConfiguration = ProxyConfigurationBuilder.newProxyConfiguration()
                .withHttpHost("serverAddress") //e.g. localhost
                .withHttpPort(portNumber) //e.g. 8001
                .build();

Adding Authentication

If your proxy server is configured to request additional authentication, such as a username and password, you need to add these to your ProxyConfiguration object. The following code sample provides a way to do so.

ProxyConfiguration httpProxyConfiguration = ProxyConfigurationBuilder.newProxyConfiguration()
                .withHttpHost("serverAddress")
                .withHttpPort(portNumber)
                .withCredentials("httpUser", "httpPwd")
                .build();

Building Your EslClient

The final step is to create your EslClient object.

For security reasons, trusting all certificates should not be enabled.

boolean allowAllSSLCertificates = false;		
EslClient client = new EslClient(API_KEY, API_URL, allowAllSSLCertificates, httpProxyConfiguration);

.NET SDK

To download the full code sample see our Code Share site.

A proxy server is a server that acts as an intermediary for requests from clients seeking resources from other servers. With OneSpan Sign, you can make API calls via a proxy server.

To make API calls to OneSpan Sign using a proxy server, you will need to build a ProxyConfiguration object. You will need to pass the proxy server's address and port number to the withHttpHost() and withHttpPort() methods respectively.

ProxyConfiguration httpProxyConfiguration = ProxyConfigurationBuilder.newProxyConfiguration()
                .WithHttpHost("serverAddress") //e.g. localhost
                .WithHttpPort(portNumber) //e.g. 8001
                .Build();

Adding Authentication

If your proxy server is configured to request additional authentication, such as a username and password, you need to add these to your ProxyConfiguration object. The following code sample provides a way to do so.

ProxyConfiguration httpProxyConfiguration = ProxyConfigurationBuilder.newProxyConfiguration()
                .WithHttpHost("serverAddress")
                .WithHttpPort(portNumber)
                .WithCredentials("httpUser", "httpPwd")
                .Build();

Building Your EslClient

The final step is to create your EslClient object.

For security reasons, trusting all certificates should not be enabled.

Boolean allowAllSSLCertificates = false;		
EslClient client = new EslClient(API_KEY, API_URL, allowAllSSLCertificates, httpProxyConfiguration);

REST API

To download the full code sample see our Code Share site.

A proxy server is a server that acts as an intermediary for requests from clients seeking resources from other servers. With OneSpan Sign, you can make API calls via a proxy server.

To make API calls to OneSpan Sign using a proxy server, you will need to build a ProxyConfiguration object. You will need to pass the proxy server's address and port number to the withHttpHost() and withHttpPort() methods respectively.

Building a WebProxy Object

The first step in making API calls to OneSpan Sign through a proxy server is to build a WebProxy object. When doing this set, the UseDefaultCredentials property to true when requests made by your WebProxy object should, if requested by the server, be authenticated using the credentials of the currently logged on user. Otherwise, set this property to false.

string proxyUri = string.Format("{0}:{1}", "serverAddress", portNumber); //e.g. 13.1.25.80:8200 
WebProxy proxy = new WebProxy(proxyUri, false)
{
        UseDefaultCredentials = false
};

Creating a HttpClient

Next, you will need to create the HttpClient that will be used to send requests to OneSpan Sign. In this example, you will need to create one with a specific handler. Note that:

  • The Proxy property sets the proxy information used by the handler.

  • The PreAuthenticate property indicates the handler will send an Authorization header with the request.

HttpClient client = null;
HttpClientHandler httpClientHandler = new HttpClientHandler()
 {
        Proxy = proxy,
        PreAuthenticate = true,
        UseDefaultCredentials = false,
};

Adding Authentication

If your proxy server is configured to request additional authentication, such as a username and password, you need to add these to your ProxyConfiguration object. The following code sample provides a way to do so.

string httpUserName = "httpUser", httpPassword = "httpPwd";
httpClientHandler.Credentials = new NetworkCredential(httpUserName, httpPassword);

Initializing a New Instance of the HttpClient

The last step is to initialize a new instance of the HttpClient class with the specific handler.

client = new HttpClient(httpClientHandler);


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence