# Using a credentials array

**URL:** https://discourse.nodered.org/t/using-a-credentials-array/26084
**Category:** General
**Created:** [4 May 2020 19:23 UTC](https://discourse.nodered.org/t/using-a-credentials-array/26084 "2020-05-04T19:23:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![peret2000](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/peret2000/32/20682_2.png) [@peret2000](https://discourse.nodered.org/u/peret2000)
#### Post date: [4 May 2020 19:23 UTC](https://discourse.nodered.org/t/using-a-credentials-array/26084/1 "2020-05-04T19:23:13Z")

</div>

Hello,  
I am not seeing the way of using an array as credentials for a node. I am trying to create a node with a list of pairs user/password, with variable length, that must be stored in the credentials file.  
But I am not able to generate the code to manage that array as credentials.  
I can design correctly a variable length list in the html code (I have based the code on the dropdown node of the dashboard), but have not been able to adapt the code to use credentials. I have tried many different options, all of them failing.  
I think it is not possible, as NR imposes that credentials must be defined specifying the type of the text: text or password, for example:

```auto
        credentials: {
            user: {type:"text"},
            password: {type:"password"}
        }

```

I have tried. as the best candidate:

```auto
        credentials: [{
            user: {type:"text"},
            password: {type:"password"}
        }]

```

with no success. I haven't found any literature about it. Does anyboy know if it is possible?  
Thanks a lot in advance

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [4 May 2020 19:52 UTC](https://discourse.nodered.org/t/using-a-credentials-array/26084/2 "2020-05-04T19:52:36Z")

</div>

Hi @peret2000

good question - not something that has ever come up before.

Looking through the code I can see a few places where it might not work as expected if you made the value a non-string type such as an array. So it is not currently possible. We would have to make a number of changes to support a new `type` of credential such as `array`. Even then, we'd have to think about how the individual values in that array would be handled as we have to treat `password` type values differently to the others whether they appear in an array or not.

---

<div class="post-metadata">

### Author: ![peret2000](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/peret2000/32/20682_2.png) [@peret2000](https://discourse.nodered.org/u/peret2000)
#### Post date: [5 May 2020 08:44 UTC](https://discourse.nodered.org/t/using-a-credentials-array/26084/3 "2020-05-05T08:44:26Z")

</div>

Thanks, @knolleary,  
I understand it is a difficult issue, and it has not interested to anybody but me 😄  
It was more as a practice to learn node creation than a real need, but indeed it is something I came up with, after using the same 'secret' keys for many nodes that did not use credentials, or, for example, when using rest api's, where it is necessary to use a user or token in the get request.

For such cases, it is handy to have a 'store' with credentials based on key/value pairs than can be selected with the key, and added to an object that will then become part of the request.

Thanks for your anwser!

---

<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: [4 July 2020 08:44 UTC](https://discourse.nodered.org/t/using-a-credentials-array/26084/4 "2020-07-04T08:44:26Z")

</div>

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