by: Kevin Broløs
The keys to the self-driving car
In order to use your QLattice, you need two key components.
You can get both of these pieces of information from the dashboard.
QLattice URL consists of two parts - our
QLattice URL, and a
It will look something like this:
On your dashboard, it can be found under
[QLattice_Name] > Details :: QLattice url.
User Access Token
User Access Token is your authentication credential for accessing the QLattice (so keep it safe). It can be found on the same dashboard page as above, under
[QLattice_Name] > Details :: User Access Token and will look something like this:
Some of you might recognize this as a JWT.
Using your credentials
You can either use them as is in the QLattice connect call
qlattice = QLattice(url="https://qlattice.abzu.ai/qlattice-a1b2c3d4", api_token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c")
or by adding the values to your environment variables, using the following two variables:
Loading into python environment from a file
Below is an example of how you could read this in from a file to either environment or save it as a string to use in the QLattice call. The contents of the files should be the token/URL, respectively, and nothing else.
Loading into environment:
import os with open('./USER_ACCESS_TOKEN.jwt', 'r') as access_token: os.environ['FEYN_TOKEN'] = access_token.read() with open('./QLATTICE_URI', 'r') as qlattice_uri: os.environ['QLATTICE_BASE_URI'] = qlattice_uri.read() qlattice = QLattice() # No parameters necessary when environments set
You can load either one or both from environment as you like, as long as you specify any other in the parameter call to the QLattice. You could also write your own parsers and load both from a single file, but this has been split for the purpose of the example.
Or loading into variable:
with open('./USER_ACCESS_TOKEN.jwt', 'r') as access_token: token = access_token.read() with open('./QLATTICE_URI', 'r') as qlattice_uri: url = qlattice_uri.read() qlattice = QLattice(url=url, api_token=token)