# Login data as global variables for different devices

**URL:** <https://discourse.nodered.org/t/login-data-as-global-variables-for-different-devices/17252>\
**Category:** General\
**Created:** [28 October 2019 19:35 UTC](https://discourse.nodered.org/t/login-data-as-global-variables-for-different-devices/17252 "2019-10-28T19:35:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![easyE4](https://avatars.discourse-cdn.com/v4/letter/e/a5b964/32.png) [@easyE4](https://discourse.nodered.org/u/easyE4)\
**Post date:** [28 October 2019 19:35 UTC](https://discourse.nodered.org/t/login-data-as-global-variables-for-different-devices/17252/1 "2019-10-28T19:35:44Z")

</div>

Hello everybody,  
I want to see the values from diffrent devices in one dashboard. The only thing I have to change  
is the IP-Adress, the user name and the password.

So I want to use a login form like you see in the picture and set this values as variables in the http-request node.

 ![node-red-flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/3547b939674247c40c59bd8cf9789a8f6d0515eb.jpeg)

What I need is a little help to realize this.

Thank you in advance for your support  
Ralf

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [28 October 2019 21:59 UTC](https://discourse.nodered.org/t/login-data-as-global-variables-for-different-devices/17252/2 "2019-10-28T21:59:04Z")

</div>

You can pass in the `url` using `msg.url` but you can not dynamically set username or password

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 October 2019 22:11 UTC](https://discourse.nodered.org/t/login-data-as-global-variables-for-different-devices/17252/3 "2019-10-28T22:11:36Z")

</div>

You should be able to pass in the basic authentication as part of the msg.headers - The name should the Authorization and the valuve should be  
Basic plus the base64-encoded username:password. For example, the Base64 version of testuser:testpwd is dGVzdHVzZXI6dGVzdHB3ZA== so the Value for the msg.headers would be

```auto
{"Authorization": "Basic dGVzdHVzZXI6dGVzdHB3ZA=="}

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [29 October 2019 00:09 UTC](https://discourse.nodered.org/t/login-data-as-global-variables-for-different-devices/17252/4 "2019-10-29T00:09:24Z")

</div>

But please remember to use https throughout if you care about security.

---

<div class="post-metadata">

**Author:** ![easyE4](https://avatars.discourse-cdn.com/v4/letter/e/a5b964/32.png) [@easyE4](https://discourse.nodered.org/u/easyE4)\
**Post date:** [29 October 2019 07:48 UTC](https://discourse.nodered.org/t/login-data-as-global-variables-for-different-devices/17252/5 "2019-10-29T07:48:52Z")

</div>

Hi, and thank you for your replys,  
first of all, please remember that you are talking to a beginner 😉

Let's get out the username and password first and focus on the IP address.  
Maybe I did not put my question right, so I would like to explain that again.

I have three devices. The only difference between these three devices is the IP address. I have now built a dashboard and all data from device 1 will be displayed. Now I want to see all data from device 2 on the dashboard. For this, the IP address must be swapped in all http-request nodes. For that I'm looking for the right solution.

It would of course be easiest for me if I could get a little example.

Thanks for your help and patience

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [29 October 2019 07:54 UTC](https://discourse.nodered.org/t/login-data-as-global-variables-for-different-devices/17252/6 "2019-10-29T07:54:08Z")

</div>

As already said. You can send the http request node the url in a message `msg.url`

You can use the change node or a function node to set the msg.url

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [29 October 2019 08:32 UTC](https://discourse.nodered.org/t/login-data-as-global-variables-for-different-devices/17252/7 "2019-10-29T08:32:32Z")

</div>

If it is an IP address you can set msg.url dynamically, as mentioned a few times above.

On the other hand, if it’s just 3 specific devices with a set username/password that doesn’t change you could take a look at `node-red-contrib-credentials` for each set, followed by a subflow of the relevant nodes such as a function node to set up basic authorisation, the http request node, and handlers to deal with the output. If it’s only 3 devices such a setup is maintainable and will solve the sending out usernames/password potential security issue from the dashboard back to the runtime as they’ll only live in the runtime.

---

<div class="post-metadata">

**Author:** ![easyE4](https://avatars.discourse-cdn.com/v4/letter/e/a5b964/32.png) [@easyE4](https://discourse.nodered.org/u/easyE4)\
**Post date:** [29 October 2019 09:46 UTC](https://discourse.nodered.org/t/login-data-as-global-variables-for-different-devices/17252/8 "2019-10-29T09:46:05Z")

</div>

454/5000  
Hi,  
I think I understand what you mean, but unfortunately can not implement, because I'm too much beginner. I do not understand the syntax of this programming tool and therefore only get error messages.

Since I do not want to waste your time, I'll give it up first and maybe try again later.

Thank you for your attempts to teach me. 👍  
Have a nice day and take care.

Ralf
