To access the Evnex API you'll need a token. To generate the token, you'll need your client ID and secret. Once you've signed up to an Enterprise account these can be found under “My Organisation” in CP-Link.
Please note that your credentials are highly sensitive, as they grant read and in some cases write access to your organisation's data. Never share your client secret insecurely, or commit your client secret into a source code repository.
Once you have your client ID and secret in hand, they'll need to be Base64 encoded. If you have openssl installed, this can be done with the following command:
echo -n 'myClientId:myClientSecret' | openssl base64
The resulting value is used in the Authorization header for the request, which has the following syntax: 'Authorization: Basic '.
The following example uses the curl command to generate an access token using the Base64 encoded client ID and secret:
curl -X POST -k -H 'Authorization: Basic <Base64 encoded credentials>' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-i 'https://auth.evnex.io/oauth2/token' \
--data grant_type=client_credentials
If the request is successful, you'll receive a response containing the access token in the following format:
{
"access_token": "<the access token>",
"expires_in": 86400,
"token_type": "Bearer"
}
To access the Evnex API, this access token must be supplied as the Authorization header with every request. For example, to get a list of all charge points in your organisation, you would make the following request:
curl -X GET -k -H 'Authorization: <the access token>' \
-i 'https://api.evnex.io/v1/charge-points/'
Tokens are valid for 24 hours, after which a new token will need to be created. If you make a request with an invalid token, you can expect to get to get a 401 Unauthorized response from the API.