Authentication#

Here are some functions to help with the handling of the authentication key.

get_auth_key(email: str, firstName: str, lastName: str, company: str = '')#

Request an auth key to use JAI-SDK with.

Parameters
  • email (str) – A valid email address where the auth key will be sent to.

  • firstName (str) – User’s first name.

  • lastName (str) – User’s last name.

  • company (str) – User’s company.

Returns

`response` – A Response object with whether or not the auth key was created.

Return type

dict

Example

>>> from jai import get_auth_key
>>> r = get_auth_key(email='email@mail.com', firstName='Jai', lastName='Z')
>>> print(r.status_code) # This should be 201
>>> print(r.json())
get_authentication(env_var: str = 'JAI_AUTH')#

Returns the authentication key if defined. See Configuring your auth key.

Parameters

env_var (str, optional) – Environment variable name. Defaults to “JAI_AUTH”.

Raises

ValueError – If no authentication key was found.

Returns

Authentication Key.

Return type

str

Example

>>> from jai import get_authentication
>>> get_authentication()
set_authentication(auth_key: str, env_var: str = 'JAI_AUTH')#

Sets the environment variable with the authentication key.

Parameters
  • auth_key (str) – Authentication key value.

  • env_var (str, optional) – Environment variable name. Defaults to “JAI_AUTH”.

Example

>>> from jai import set_authentication
>>> set_authentication("xXxxxXXxXXxXXxXXxXXxXXxXXxxx")