Show / Hide Table of Contents

Configuring Proxy Credentials

Introduction to Proxy Credentials

To support requesting data from external sources via the internet, some proxy servers may require specific credentials for access. To support this configuration, the TT .NET SDK requires access to the user's proxy credentials to make the required requests.

Note: In order to connect to a proxy server that requires credentials, you must configure a ProxyCredentialsHandler when creating your application.

Configuring the ProxyCredentialsHandler

When connecting to a proxy server that requires credentials, the TT .NET SDK requests the credentials from the application via the ProxyCredentialsHandler. The credentials provided by the application will be handed to the proxy which, if valid, should allow the TT .NET SDK to access the external internet resources.

The ProxyCredentialsHandler defined in the TTAPI object provides the mechanism to pass proxy credentials to the SDK. When creating your application, configure the handler and pass it into the CreateTTAPI method.

Note: This is an optional handler and may be omitted if the application does not need to support proxies that require credentials.

ProxyCredentialsHandler example

The following code snippet demonstrates an example of this process.

public void Init(tt_net_sdk.TTAPIOptions TTAPIOptions)
{
    // hook up the handler for when the TTSDK is initialized 
    ApiInitializeHandler apiInitHandler = new ApiInitializeHandler(ttApiInitComplete);
    // hook up the proxy handler to account for the potential need for 
    // proxy login credentials to make external https requests & websocket connection
    ProxyCredentialsHandler proxyHandler = new ProxyCredentialsHandler(OnProxyCredentials);
    TTAPI.CreateTTAPI(tt_net_sdk.Dispatcher.Current, TTAPIOptions, apiInitHandler, proxyHandler);
}

public void OnProxyCredentials(CredentialsNeededEventArgs e)
{
    // supply the SDK with the appropriate credentials for the proxy login
    // application to decide how to acquire the data from the user
    // once the creds are known,set the values in the CredentialsNeededEventArgs
    e.UserName = "username_for_proxy";
    e.UserPwd = "userpassword_for_proxy";
}

Overriding the system configured proxy

You can override the system configured proxy by setting the TTAPI.ProxyUri property equal to the Uniform Resource Identifier of your desired proxy server.

In this article
Back to top