---
id: creating-a-connection
slug: /sdk/dotnet/creating-a-connection
title: 'Creating a Connection DOTNET SDK'
description: 'This topic explains how to connect the Digital.ai Agility with .NET SDK'
sidebar_label: 'Creating a Connection'
sidebar_position: 2
tags: ['access-tokens', 'basic-authentication', 'windows-integrated-authentication']
---

This topic explains how to connect the Digital.ai Agility with .NET SDK.

## Overview

Connecting to the Digital.ai Agility API via the .NET SDK involves determining the URL of your Agility instance, determiningthe 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("YOUR_ACCESS_TOKEN")
            .Build();
        
```

A few things to point out abut the **V1Connector**:

- The Server Base URIis the URL that you use for your Agility 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.

Access Tokens is the preferred connection method.

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 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**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 Agility member account that you want to connect with:

```
            V1Connector connector = V1Connector
            .WithInstanceUrl("<Server Base URI>")
            .WithUserAgentHeader("AppName", "1.0")
            .WithAccessToken("YOUR_ACCESS_TOKEN")
            .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 **UseOAuthEndpoints**method 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("YOUR_ACCESS_TOKEN")
            .UseOAuthEndpoints()
            .Build();
        
```

## 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("YOUR_ACCESS_TOKEN")
            .WithProxy(proxyProvider)
            .Build();
        
```

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