Page summary
Integrations: Auth with applications
1 - Navigate to the Applications Page
To list existing applications, or create a new one, navigate to the Administration -> Integrations -> Applications page.
2 - Create a New Application
Click on the +Add New button to create a new application if its needed.
3 - Get the keys
Edit the application, and now it should display the public and the private keys.
In this example, the public-key is "58b8d238-3cfc-41a0-aaad-ae6077d7c4e0" and the private-key is "ca626c20-659d-4553-8647-2337c0a8804d".
3 - Concatenate the keys
Now we need to concatenate the public and private keys into a single string.
const publicKey = "58b8d238-3cfc-41a0-aaad-ae6077d7c4e0";
const privateKey = "ca626c20-659d-4553-8647-2337c0a8804d"
const keysString = publicKey + privateKey;
This will generate the following string:
keysString = "58b8d238-3cfc-41a0-aaad-ae6077d7c4e0"ca626c20-659d-4553-8647-2337c0a8804d"
4 - Hash the keys
Hash the string using the SHA-256 algorithm.
In this case it would be:
sha256KeysString = "1056e1342f844577aff4f99d146e3dcde1364dfa60aafd6a63f9379e0b7e06de"
5 - Concatenate the app name with the generated hash
Next we need to append the appname to the sha256KeysString.
App_name + ":" + sha256KeysString
In this case it would be:
Test:1056e1342f844577aff4f99d146e3dcde1364dfa60aafd6a63f9379e0b7e06de
6 - Encode the app name and the hash
Next we need to use the base64 algorithm to encode the string.
echo -n "Test:1056e1342f844577aff4f99d146e3dcde1364dfa60aafd6a63f9379e0b7e06de" | base64
The result in this case is something like this:
cGFnb2V4cHJlc3M6MTA1NmUxMzQyZjg0NDU3N2FmZjRmOTlkMTQ2ZTNkY2RlMTM2NGRmYTYwYWFmZDZhNjNmOTM3OWUwYjdlMDZkZQ==
6 - Get the application token
Now we need to use the POST /accounts/applications endpoint to authenticate using the application.
Setting the Basic Authorization header to the value of the generated hash, it should look like this:
"Authorization": "Basic cGFnb2V4cHJlc3M6MTA1NmUxMzQyZjg0NDU3N2FmZjRmOTlkMTQ2ZTNkY2RlMTM2NGRmYTYwYWFmZDZhNjNmOTM3OWUwYjdlMDZkZQ=="
"X-API-KEY": "58b8d238-3cfc-41a0-aaad-ae6077d7c4e0"
"Content-Type": "application/json"
The response will contain the publicKey and the token that will be used to authenticate the application.
{
"publicKey": "57d0398c-4705-4d84-a9ad-7e3ca741497b",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJfaWQiOiI2MGE3YjIyMDVjYzkyYzNhOTExMzYzMzAiLCJhY2NvdW50SWQiOiI1OTVmOWM3MDA3ZWUxMjY4NmQwMDAwMzIiLCJ1c2VySWQiOiI2MGE3YjIyMDVjYzkyYzNhOTExMzYzMzAiLCJuYW1lIjoicGFnb2V4cHJlc3MiLCJkZXNjcmlwdGlvbiI6IkFwcGxpY2F0aW9uIGZvciBkYXRhbG9naWMgcGFnbyBleHByZXNzIGludGVncmF0aW9uIiwiaW50ZXJuYWwiOmZhbHNlLCJwcmVtaXVtIjpbXSwiaWF0IjoxNzE2NDAyNjA2LCJleHAiOjE3MTY1NzU0MDYsImF1ZCI6InBhZ29leHByZXNzIiwiaXNzIjoiYnRyei1hcGktYWNjb3VudHMiLCJzdWIiOiJhY2NvdW50X3VzZXJfc2lnbl9pbiJ9.TiBFtHb2Nrkv8tFt-UHk7wNr-VLQZAhdQM7EALaZbag0T_XJTboj67oe7GNkv0YVIAc9ZXXtNsMdoUecM7TjeQ"
}
7 - Use the application token
Now you can use the publicKey and the token to use in endpoints that needs the application authorization.
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJfaWQiOiI2MGE3YjIyMDVjYzkyYzNhOTExMzYzMzAiLCJhY2NvdW50SWQiOiI1OTVmOWM3MDA3ZWUxMjY4NmQwMDAwMzIiLCJ1c2VySWQiOiI2MGE3YjIyMDVjYzkyYzNhOTExMzYzMzAiLCJuYW1lIjoicGFnb2V4cHJlc3MiLCJkZXNjcmlwdGlvbiI6IkFwcGxpY2F0aW9uIGZvciBkYXRhbG9naWMgcGFnbyBleHByZXNzIGludGVncmF0aW9uIiwiaW50ZXJuYWwiOmZhbHNlLCJwcmVtaXVtIjpbXSwiaWF0IjoxNzE2NDAyNjA2LCJleHAiOjE3MTY1NzU0MDYsImF1ZCI6InBhZ29leHByZXNzIiwiaXNzIjoiYnRyei1hcGktYWNjb3VudHMiLCJzdWIiOiJhY2NvdW50X3VzZXJfc2lnbl9pbiJ9.TiBFtHb2Nrkv8tFt-UHk7wNr-VLQZAhdQM7EALaZbag0T_XJTboj67oe7GNkv0YVIAc9ZXXtNsMdoUecM7TjeQ"
"X-API-KEY": "57d0398c-4705-4d84-a9ad-7e3ca741497b"