I try to deploy a flow via Admin HTTP API containing credentials in nodes properties. In my case it's a node of type mqtt-broker. The security tab contains a property user
which I try to put within the API call.
This property is stored in flows_<hostname>_cred.json
. Like this post stated this file could be encrypted. In my case in settings.js
it's set to credentialSecret: false
.
Is it possible to pass values stored in flows_<hostname>_cred.json
within the Admin HTTP API? Or is the only method replacing the file locally?
Edit
Test flow I sent to https://127.0.0.1:1880/flows
, returns HTTP code 204.
[
{
"id": "f71b8c17.05ad3",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "baa95a0d.e490e",
"type": "mqtt in",
"z": "f71b8c17.05ad3",
"name": "",
"topic": "",
"qos": "2",
"datatype": "auto",
"broker": "e8482c08.9858f",
"x": 120,
"y": 180,
"wires": [
[
"bd237434.8030a"
]
]
},
{
"id": "bd237434.8030a",
"type": "debug",
"z": "f71b8c17.05ad3",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 320,
"y": 180,
"wires": []
},
{
"id": "e8482c08.9858f",
"type": "mqtt-broker",
"z": "",
"name": "test",
"broker": "test",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]
This does not work for me if I add "user": "TEST"
in e8482c08.9858f
.
You don't directly pass data to the creds file, this is handled for you by the runtime.
You need to add the creds attributes to the matching nodes in the flow you then post to the admin api. They will then be stripped out, encrypted and added to the creds file.
So for the mqtt-broker config node you would add the user
and password
fields in a field called credentials. As described in the docs here https://nodered.org/docs/creating-nodes/credentials