---
title: Integrating the OpenToken agent into your .NET application
description: To use the .NET Integration Kit, modify your application to use the OpenToken Agent.
component: net
page_id: net:setup:pf_net_ik_integrating_the_opentoken_agent_into_your_net_application
canonical_url: https://docs.pingidentity.com/integrations/net/setup/pf_net_ik_integrating_the_opentoken_agent_into_your_net_application.html
revdate: June 27, 2024
section_ids:
  sample-code: Sample code
---

# Integrating the OpenToken agent into your .NET application

To use the .NET Integration Kit, modify your application to use the OpenToken Agent.

The agent API allows your web application to directly read or write an OpenToken package.

Instantiate the OpenToken Agent by invoking a constructor and loading the `agent-config.txt` configuration file that you saved in [Configuring an OpenToken SP Adapter instance](pf_net_ik_configuring_an_opentoken_sp_adapter_instance.html). This configuration file includes the name of the cookie that the agent object will write, as well as the key to use when encrypting a new OpenToken. If the agent does not find an agent-config.txt file, it throws an exception.

## Sample code

Modify your .NET application based on the following sample code.

```
using System;using System.
Collections.Generic;
using System.Text;
using opentoken;
using System.IO;
using opentoken.util;
using System.Collections;
using System.Collections.Generic;
. . . .
Agent agent = new Agent( "<PATH_TO_FILE>/agent-config.txt");
```
