Environment Setup
Intro
Infinipoint’s API uses JSON Web Token (JWT) for authentication.
JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object.
Using your private key (will be provided by Infinipoint), you will need to sign the request with an Elliptic Curve Digital Signature Algorithm (ECDSA) using the ES256 algorithm.
Please refer to this page for more details on general usage.
Note: This guide assumes you already have Python3 and pip3 (python package manager) installed and set in your PATH.
Software Dependencies
In order to sign this JWT token with Python3, you will need to install some OS dependencies and Python packages.
Additional installation instructions for specific OS types can be found here -
Python required Packages
The following Python packages are required in order to execute the Python examples:
cryptography==37.0.4
PyJWT==2.4.0
requests==2.28.1
Save the above as requirements.txt, and execute the following command to install the them:
pip3 install --upgrade -r requirements.txt
Note: the cryptography package has some OS dependencies.
If you are having trouble installing it, please refer to their documentation for detailed instructions for your OS.
Avoiding Dependency Hell using Docker
Intro
In order to avoid specific OS dependencies, we have created a public Docker container which you can use.
Execute the following command to run this container.
docker run -e ACCESS_KEY_ID="<your-access-key-id>" -e SECRET_ACCESS_KEY="<your-secret-access-key>" -it public.ecr.aws/j1x7x4l5/infinipoint-api-python:latest
Executing Your Own Entrypoint
By default, it will print the devices which are registered with your tenant using the /devices
route (see this example).
You can overwrite the default entrypoint script to execute your custom script.
Follow the below steps to overwrite the script:
Create your own custom script which queries the Infinipoint API.
Save the script with the following name:
entrypoint.py
In the same folder where the script is saved execute the following command to create a Dockerfile:
Build the docker container:
Run the container to execute the script:
Note: If you script contains the
ACCESS_KEY_ID
andSECRET_ACCESS_KEY
as hard-coded values (like in the examples section), there is no need to pass them as environment variables.