# Generating a Session ID

Before running the build scan and tests, you need to create a session ID. The session ID is provided to each step in order link them together as one complete cycle.

Download a token from the SeaLights dashboard and place the `sltoken.txt` file in the working directory

{% hint style="info" %}
See '[Generating an Agent token](https://docs.sealights.io/knowledgebase/settings/token-access-and-management#token-list-and-token-creation-2)' for instructions on how to generate a token
{% endhint %}

## Agent File <a href="#agent-file" id="agent-file"></a>

Our Python agent is published in Python PyPi repository: [![](https://pypi.org/static/images/favicon.35549fe8.ico)sealights-python-agent](https://pypi.org/project/sealights-python-agent/)\
You can download it and all its dependencies using the following command:

{% code overflow="wrap" lineNumbers="true" %}

```
pip install sealights-python-agent
```

{% endcode %}

When installing a specific version, you have to mention it explicitly

{% code overflow="wrap" lineNumbers="true" %}

```
pip install sealights-python-agent==2.2.5
```

{% endcode %}

{% hint style="info" %}
The agent uses the `cryptography` package which requires OpenSSL libraries and include files.\
On Linux this is usually available but on Windows systems, you might need to install it and add it to the LIB & INCLUDE folders
{% endhint %}

## Generating a session ID in Python <a href="#generating-a-session-id-in-python" id="generating-a-session-id-in-python"></a>

Generating a session ID in Python is done using the SeaLights Python Agent with the config flag

{% code overflow="wrap" lineNumbers="true" %}

```
sl-python config --appname myApp --branchname master --buildname 1 --exclude "*venv*","*tests*" [--workspacepath /path/to/app]
```

{% endcode %}

{% hint style="info" %}
Each time the command runs, the `app/branch/build` trio must be unique to create a new entry in your SeaLights instance. Usually, only `buildname` changes—make sure to generate a unique one each time. For that purpose, you can use a timestamp, e.g., `--buildname $(date +"%y%m%d_%H%M")` (Linux/macOS).
{% endhint %}

### Using the session ID <a href="#using-the-session-id" id="using-the-session-id"></a>

The session ID will be printed to the console output and a file called 'buildSessionId.txt' will be generated containing it.

The file can be used as is in the agent parameters or can be used to fill in an environment parameter to be in a command line.

#### Copying token to environment variable

{% tabs %}
{% tab title="Unix" %}
{% code overflow="wrap" lineNumbers="true" %}

```
export SL_BUILD_SESSION_ID=`cat buildSessionId.txt`
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}
{% code overflow="wrap" lineNumbers="true" %}

```
set /p SL_BUILD_SESSION_ID=<buildSessionId.txt
```

{% endcode %}
{% endtab %}
{% endtabs %}
