API Key Support
The API Key for EMCC Integration is optional and can be disabled by modifying the appsettings.json file
.
To deactivate API Key authentication, you can either remove the entire "Authentication" section from the file or set the value of "UseApiKey" to false within the configuration.
"Authentication": {
"UseApiKey": false
},
Generate an API Key
To use API Key authentication, you will need to generate an API Key. You can generate a new API Key for each user or system that needs to access the API.
Add the Authentication object to your configuration file
In your configuration file, add an "Authentication" object with the following attributes:
UseApiKey
- a Boolean value that indicates whether API Key authentication should be used.ApiKeys
- an array of API Key strings that will be accepted by the API.
Here is an example of how the "Authentication" object should look like with API Key support enabled:
"Authentication": {
"UseApiKey": true,
"ApiKeys": []
},
Insert the API Key into the "ApiKeys" array in the configuration file
In the "ApiKeys" array in the "Authentication" object in your configuration file, add the API Key string that you generated earlier. This will allow the API to authenticate requests using the API Key.
Here is an example of how the "Authentication" object should look like with the API Key inserted:
"Authentication": {
"UseApiKey": true,
"ApiKeys": ["Example-API-Key"]
},
Here is an example with multiple API Keys:
"Authentication": {
"UseApiKey": true,
"ApiKeys": ["Example-API-Key-1","Example-API-Key-2"]
},
Replace "api-key" with the actual API Key string that you generated earlier.
Send requests with the API Key
To send requests with the API Key, include the API Key in the "X-Api-Key" header of your HTTP requests, like this:
curl -X 'GET' \
'http://dev.ewa.bliksund.com/Integration' \
-H 'X-Api-Key: Example-API-Key'
Replace api-key
with the actual API Key string that you generated earlier.