This is necessary when you run scripts with the cjapy library on certain server environments (e.g. Google Cloud) instead of locally (e.g. in a Jupyter Notebook.
In such environments, referring to config.json may not work.
In that case, you can pass the variables to the configure method available.
In windows command line:
setx NEWVAR SOMETHING
In Powershell:
$Env:<variable-name> = "<new-value>"
Linux / Unix / iOS shells:
export NAME=VALUE
You can then access the different values in your python script by realizing the following command:
import os
USER = os.getenv('API_USER')
PASSWORD = os.environ.get('API_PASSWORD')
...
The cjapy
module provide a configure method that will set the correct value to be used in the module.
import os
my_org_id = os.getenv('org_id')
my_tech_id = os.environ.get('tech_id')
my_secret = os.environ.get('secret')
my_client_id = os.environ.get('client_id')
my_scopes = os.environ.get('scopes')
import cjapy
cjapy.configure(org_id=my_org_id,tech_id=my_tech_id, secret=my_secret,client_id=my_client_id,scopes=my_scopes)
Starting this point, you can use the cjapy
module as explained in the documentation.