Skip to main content
Version: Early Access

Creating a Connection

Connecting to the Digital.ai Agility API via the Java SDK involves determining the URL of your VersionOne instance, determining the API authentication type that you want use, determining your proxy credentials (if you use one), and then building a connection object. To build a connection object you'll use the V1Connector object which is implemented using a fluent builder interface.

Here's an example of how to use the V1Connectorwith an access token:

            V1Connector connector = V1Connector
.withInstanceUrl("<Server Base URI>")
.withUserAgentHeader("AppName", "1.0")
.withAccessToken("1.rWM8lKLk+PnyFxkEWVX5Kl2u6Jk=")
.build();

A few things to point out abut the V1Connector:

  • The Server Base URL is the URL that you use for your Agility instance and is typically in the form of
  • The user agent header is used to pass the name and version number of your application to the API which can help with log analysis should there be an issue.
  • The build method is the builder's terminating method and returns the V1Connector object which you will then pass to other objects when performing actions with the API.

The V1Connectoris a new connector released with the 15.0.0.0 version of the Java SDK, and it replaces the legacyV1APIConnector. The legacy connector is still available for use within the SDK but has been marked for deprecation. It will be removed in a future release.

Connecting with Basic Authentication

When using Basic authentication, you use the withUsernameAndPasswordmethod, passing in the username and password of the Agility member account that you want to connect with:

            V1Connector connector = V1Connector
.withInstanceUrl("<Server Base URI>")
.withUserAgentHeader("AppName", "1.0")
.withUsernameAndPassword("username", "password")
.build();

Connecting with Windows Integrated Authentication

When using Windows Integrated Authentication, you use the withWindowsIntegratedmethod. If you want to use the SDK with the currently logged in user's account, you do not need to pass any parameters:

            V1Connector connector = V1Connector
.withInstanceUrl("<Server Base URI>")
.withUserAgentHeader("AppName", "1.0")
.withWindowsIntegrated()
.build();

Unlike the .NET SDK, the Java SDK does not support using Windows Integrated Authentication with specific user credentials, you can only use the credentials of the currently logged in user.

Connecting with Access Tokens

When using Access Token Authentication,you use the with AccessTokenmethod, passing in the access token associated with the Digital.ai Agility member account that you want to connect with:

            V1Connector connector = V1Connector
.withInstanceUrl("<Server Base URI>")
.withUserAgentHeader("AppName", "1.0")
.withAccessToken("1.rWM8lKLk+PnyFxkEWVX5Kl2u6Jk=")
.build();

When trying to use an access token when your Agility instance has been configured to use Windows Integrated Authentication, you will need to use the special useOAuthEndpointsmethod of the connector. This method allows the connectorto bypass NTLM and authenticate directly to the API with an access token.

            V1Connector connector = V1Connector
.withInstanceUrl("<Server Base URI>")
.withUserAgentHeader("AppName", "1.0")
.withAccessToken("1.rWM8lKLk+PnyFxkEWVX5Kl2u6Jk=")
.useOAuthEndpoints()
.build();

Connecting with a Proxy

If you are using a proxy in your environment, you can use the withProxymethod, passing in a ProxyProviderobject hydrated with the URL, username, and password used to authenticate with the proxy:

            ProxyProvider proxyProvider = new ProxyProvider(new URI("proxyURL"), "proxyUsername", "proxyPassword");

V1Connector connector = V1Connector
.withInstanceUrl("<Server Base URI>")
.withUserAgentHeader("AppName", "1.0")
.withAccessToken("1.rWM8lKLk+PnyFxkEWVX5Kl2u6Jk=")
.withProxy(proxyProvider)
.build();

You cannot use a proxy when connecting with Windows Integrated Authentication.