# Python client for obtaining Grass session tokens
___
This Python client is designed to programatically obtain a Grass session token
for a given vend contact ID. This facilitates integration testing where a
session token is required.

Getting Started
---------------

### Installation

```
pip install -i https://pypi.theorchard.io/pypi/ qa-utils-grass
```

Usage
-----

#### Getting a session token

In order to get a Grass session token, first make sure you define the following
environment variables:

* QA_DB_HOST - host for QA database, e.g. qadb01.qaorch.com
* QA_DB_DATABASE - database name, e.g. art_relations
* QA_DB_USER - database user to make the connection, e.g. my_user
* QA_DB_PASS - database user's password
* QA_GRASS_HOST - Grass host, likely https://api-dev.theorchard.io/auth/session

Once you have defined these environment variables, you can import GrassAuth and
UserType and create a new instance with your desired UserType (and vend contact
ID if UserType.WORKSTATION) and call the grass_token property which will
provide you with a Grass token.

See below:

Example:

```python

from auth.auth import GrassAuth, UserType

# Example of getting a session token
workstation_token = GrassAuth(UserType.WORKSTATION, 38271).grass_token
print(workstation_token)
oa_token = GrassAuth(UserType.OA).grass_token
print(oa_token)
```
