Skip to main content
System StatusContact Support
VersionOne Community

Creating a Connection

Overview

Connecting to the VersionOne API via the .NET 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 class which is implemented using a fluent builder interface.

Here's an example of how to use the V1Connector with 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 URI is the URL that you use for your VersionOne instance and is typically in the form of "http(s)://server name/instance name".
  • 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 V1Connector is a new connector released with the 15.0.0.0 version of the .NET SDK. It replaces all other legacy connectors like V1APIConnector and VersionOneAPIConnector. The legacy connectors are still available for use within the SDK but have been marked for deprecation. They will be removed in a future release.

Connecting with Basic Authentication

When using Basic authentication, you use the WithUsernameAndPassword method, passing in the username and password of the VersionOne 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 WithWindowsIntegrated method. 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();

If you need to use the account of a specific user, you can use the overloaded version of the WithWindowsIntegrated method, passing in the fully qualified domain\username and password of the user's account:

V1Connector connector = V1Connector
    .WithInstanceUrl("<Server Base URI>")
    .WithUserAgentHeader("AppName", "1.0")
    .WithWindowsIntegrated("DOMAIN\\username", "password")
    .Build();

Connecting with Access Tokens

When using Access Token Authentication, you use the WithAccessToken method, passing in the access token associated with the VersionOne 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 VersionOne instance has been configured to use Windows Integrated Authentication, you will need to use the special UseOAuthEndpoints method of the connector. This method allows the connector to 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 OAuth2 Tokens

As of Winter 2016 release notes our intent is to sunset OAuth2 in favor of Access Tokens. 

When using OAuth2 Authentication, you use the WithOAuth2Token method, passing in the OAuth2 access token associated with the VersionOne member account that you want to connect with:

V1Connector connector = V1Connector
    .WithInstanceUrl("<Server Base URI>")
    .WithUserAgentHeader("AppName", "1.0")
    .WithOAuth2Token("AAEAAJa0PvSSjkBYffqqU2f5oPCFLimIhiiQaiM04VO-5p7Nmlm0W9bqM59-...")
    .Build();

The .NET SDK only supports connecting with a valid OAuth2 access token, it does not do the full authorization of the token, nor does it refresh the token. If you wish to use OAuth2 as your authentication method, you may want to use a third-party library like DotNetOpenAuth or OAuth.netto assist with generating and refreshing your OAuth2 access tokens.

Connecting with a Proxy

If you are using a proxy in your environment, you can use the WithProxy method, passing in a ProxyProvider object 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.

  • Was this article helpful?