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

**URL:** <https://discourse.nodered.org/t/can-i-pass-global-variables-into-the-username-and-password-of-a-http-request-node/63456>\
**Category:** General\
**Created:** [4 June 2022 15:24 UTC](https://discourse.nodered.org/t/can-i-pass-global-variables-into-the-username-and-password-of-a-http-request-node/63456 "2022-06-04T15:24:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![championc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/championc/32/39754_2.png) [@championc](https://discourse.nodered.org/u/championc)\
**Post date:** [4 June 2022 15:24 UTC](https://discourse.nodered.org/t/can-i-pass-global-variables-into-the-username-and-password-of-a-http-request-node/63456/1 "2022-06-04T15:24:14Z")

</div>

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 \*\*\*\*\*\*

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [5 June 2022 10:46 UTC](https://discourse.nodered.org/t/can-i-pass-global-variables-into-the-username-and-password-of-a-http-request-node/63456/2 "2022-06-05T10:46:45Z")

</div>

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:

```auto
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 -`)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [5 June 2022 10:48 UTC](https://discourse.nodered.org/t/can-i-pass-global-variables-into-the-username-and-password-of-a-http-request-node/63456/3 "2022-06-05T10:48:28Z")

</div>

> [@bakman2](#):
>
> `new Buffer`

`new Buffer` is depreciated. Should be using `Buffer.from` 🙂

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [5 June 2022 10:50 UTC](https://discourse.nodered.org/t/can-i-pass-global-variables-into-the-username-and-password-of-a-http-request-node/63456/4 "2022-06-05T10:50:07Z")

</div>

i stand corrected 😉 modified.

---

<div class="post-metadata">

**Author:** ![Byteman](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@Byteman](https://discourse.nodered.org/u/Byteman)\
**Post date:** [14 June 2022 12:18 UTC](https://discourse.nodered.org/t/can-i-pass-global-variables-into-the-username-and-password-of-a-http-request-node/63456/5 "2022-06-14T12:18:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 August 2022 12:18 UTC](https://discourse.nodered.org/t/can-i-pass-global-variables-into-the-username-and-password-of-a-http-request-node/63456/6 "2022-08-13T12:18:15Z")

</div>

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