Can I pass Global variables into the Username and Password of a HTTP Request Node

Hi all,

I was hoping to store a Username and Password in global variables, set from a sort of Control Panel, and then use them in a HTTP Request Node. But how would I pass a password since it's all hidden with ******

You can use a function node to prepare the details for the http request node

Depending on the request you want to make you could do something like:

const user ="myuser" // global.get("myuser")
const password = "mypassword" // global.get("mypassword")
const secret = user+":"+password
const hash = Buffer.from(secret).toString('base64')

msg.method ='POST'
msg.url = "https://myurl"
msg.headers = {}
msg.headers['Authorization'] = 'Basic '+ hash
msg.headers['Content-Type'] = 'application/x-www-form-urlencoded'

return msg

and pass this to the http request node (make sure to set the method in the request node to - set by msg.method -)

2 Likes

new Buffer is depreciated. Should be using Buffer.from :slight_smile:

1 Like

i stand corrected :wink: modified.

1 Like

Hello,

Could I pass user and password as parameters for Digest Authentication?

Currently my flow works fine with hardcoded credentials in the HTTP Request node and presetting headers for Digest Authentication but I would like to pass user and password as parameters rather than hardcoding them.

Thank you.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.