Http request with dynamic credentials

Hello everyone!

I'm building in node-red a central controller for various audio/video equipment.
they have a web interface, so an easy way to control them is to use the node http-request.

This works great, however some of the equipments are using authentication, and i would like to use sort of a database for the credentials. At this point the only problem i have is that the built-in http request node does not allow the credentials to be passed as an input message.

Do you know if a contributed node could do it?

Also, i'm wondering if i could build a modified http request node wich could do that (mainly as a way to learn more :slight_smile: ).
To do so i've found the node-red core with the function i'm interessed in there:

But couldn't find this node in the.node-red/ folder on my system (mac). Do you know where it should be located?

Thanks a lot for your help!

If the credentials are basic auth or a bearer token, then you can pass them in as headers

Thanks a lot for your answer, i figured a way for Basic auth in the form of a function node (attached) which create the http get header with auth and send it in a tcp request. I didn't know it was possible to pass the header directly to the http request, thanks!

However for the digest auth, which i also need for some device seems a bit trickier to implement that way...

i found the core nodes to be stored here, if anyone wonders:

ar err = false;

if (msg.url === undefined || msg.url ==="")
    node.error("URL error");
    err = true;
if (msg.port === undefined || msg.port ===0)
    node.error("port error");
    err = true;
if ( === undefined || ==="")
    node.error("HOST error");
    err = true;
if (err)

var authorization = "";
var connection = "close";
//const timeout = 30;
//const keep_alive = true;

if (msg.timeout !== undefined && msg.timeout > 0)
    connection = "keep-alive\r\n";
    connection += "Keep-Alive: timeout="+msg.timeout+"\r\n";
//var connection = "keep-alive";

if( !== undefined && msg.pass !== undefined)    
    if( !== "" && msg.pass !== "")
        authorization = "Authorization: Basic "+encodeB64(':'+msg.pass)+" \r\n";

msg.payload="GET "+msg.url+" HTTP/1.1\r\nuser-agent: node-red\r\n"+authorization+"Host: ""\r\n"+"Connection: "+connection+"\r\n\r\n";

return msg;

function encodeB64(data)
    var buf = new Buffer(data);
    return buf.toString('base64');

function decodeB64(data)
    var buf = new Buffer(data, 'base64');
    return buf.toString('ascii');

Read the built in help of a node when you are unsure. Sometimes it is actually helpful - who knew :wink:

Also, in the latest node red (v3+) you can set headers in the UI

thanks, it seems that i should upgrade to 3!
Yeah, i read the help, it is more that i'm not that used to http or more basically web design... :woozy_face:
But i'm really happy to learn and grateful for the help i found for node-red!

1 Like

WOW, really i don't now much about basic web developpment and http.

I just figured out that an url can contains credentials in the form of user:pass@hostname

this works however only for basic auth. Is it a way to do something similar for digest auth?

again thanks for the community and this incredible tool that node-red is!