< To nexusgroup.com
This article describes how to add a new API user in the Nexus Push Service to get a unique API key to use.
Expand/Collapse All
Navigate to the top-level directory where docker-compose.yml is located. The config file should then be found in a config/ directory.
mydir/ |-- cacerts |-- certificates |-- config | |-- application.yml -> cod-nps.yml | `-- cod-nps.yml `-- docker-compose.yml
Open the configuration file for editing:
vi config/cod-nps.yml
Open a browser and go to the following URL, using a unique <myclientid>:
<myclientid>
http://localhost:20200/<contextPath>/<uriBase>/util/generateclient/<myclientid>
Find port number
All requests below are triggered from the host itself, thus localhost is used.
Please note that the port number might have been assigned a different value. To find out the current port number, type:
docker ps | grep nps_nps
Copy the content from the resulting web page and paste it into the allowedClients section of the configuration file.
allowedClients
# X-Api-Key: a2Fyb2xpbjpmZDA0ZGUyZjFlNTU0NGIyOTE1ZEJhNjUwOThjNDkwNjM3YTA3MTVmNWM5ODQzNDU5ZjA1ZGZjMjk4MzQyOTM2 - clientId: <myclientid> key: fd04de2f1e5544b2915d1a65098c490637a0715f5c9843459f05dfc298342936
Make sure not to add extra spaces in the configuration file, since the .yml file format is space sensitive.
Refresh the configuration:
curl -X POST http://localhost:20200/<contextPath>/refresh
Test the new key by sending a request using curl (set THE-NEW-KEY below):
THE-NEW-KEY
curl -w%{http_code} -X POST \
https:
//nps.nexusgroup.com/notification/push \
-H
'cache-control: no-cache'
\
'content-type: application/json'
'x-api-key: THE-NEW-KEY'
-d '{
"pushId"
:
"api-test"
,
"title"
"This is a test"
"body"
}'
{"result":{"status":"ERROR"}}404
This response means that the pushId is wrong, which is expected at this point.
pushId