Hello,
i am not sure if it is possible to send authentication username and password to http-request node. So when I have more nodes of this type, if I can manage the username and password from a global variable for example. Thanks.
it is possible to include the username and password in the URL http://user:pass@wherever.com
.
The HTTP node extracts them and uses the with auth type (basic/digest) you set on node.
Alternatively, depending on the auth type, you can probably set the Authorization
header yourself (either in the HTTP node edit dialog or via a change/function node before the HTP request.
basic auth example
const user = flow.get('user')
const pass = flow.get('pass')
msg.headers = msg.headers || {}
msg.headers.Authorization = "Basic " + Buffer.from(`${user}:${password}`).toString("base64");
Alternatively, you can use Env Vars for setting the username and password.
Here is an example of basic authorization in a change node.
[{"id":"bba0f53aec84ae5f","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"set","p":"user","pt":"msg","to":"user","tot":"global"},{"t":"set","p":"password","pt":"msg","to":"password","tot":"global"},{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers.Authorization","pt":"msg","to":"\"Basic \" & $base64decode($$.user & \":\" & $$.password)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":5240,"wires":[[]]}]
Thanks all for great and fast help. I think, I will use the Change node, which will do, what I need. Great. Thanks.
Please lets use https
in any logon examples. And please note that even with https, you are leaking your id and password to the Internet. This is HIGHLY INSECURE.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.