Obtaining Machine-to-Machine Secrets
You must be logged in as an admin in your team to obtain machine-to-machine secrets. In the Vijil web interface, click on your profile icon in the lower left. Here, you can view and rotate your long-lived machine-to-machine secrets. These can be viewed only once and must be rotated after the initial viewing. Click View long-lived token to view the secrets. This option is available if they have not been viewed yet. If someone else in the team has already viewed them, you will have to rotate the secrets. Click Rotate long-lived token to rotate the secrets, then click View long-lived token to view the new secrets. The secrets displayed are the Client ID, Client Secret, and Client Token. Save these as variables in an environment file. Sample environment file:.env.example
Obtaining an Authentication Token
To use the Vijil Python SDK to run CI/CD scripts, you will need to use the long-lived secrets to obtain an authentication token. To do so, you send a POST request to the token endpoint. The following Python snippet shows how to do so, assuming you have saved the secrets to an.env file like the one above.
Save the Access Token to Your Envionrment
Now you can usesimple_access_token to authenticate requests to the Vijil Evaluate API. Save it as VIJIL_API_KEY in your environment file and you can run the code samples in our quickstart.
The access token expires after 24 hours, so you should use the above script to refresh it if you are making API calls more than 24 hours apart.