Credentials undefined

I followed the instructions on this page to change some of my node's properties to credentials. Now they're always undefined. Whatever I enter cannot be accessed in the node at runtime. The node editor also loses all input after saving.

What else do I have to do to make it work? The documentation is incomplete or wrong. Is there an example somewhere? Google doesn't find anything about this topic, which gives me the impression that nobody uses that credential feature. Where is that data stored on disk?

Lots of nodes use the credentials feature. So before you assume the feature is broken or the docs wrong, how about starting with the assumption you may have made a mistake in implementing it.

Without any details of what you have done, we can't tell you what to do differently or what's missing. If you share some details we can help check.

1 Like

You're asking what I've done? I've followed the documentation. Exactly as described there. Would you like me to repeat it here for you?

I have reason to believe there are some errors in the documentation. At least it is contradictory to itself.

  1. The part about adding the credential fields is duplicate. Point 1 and 3 are identical, with point 3 being more clear.
  2. The editor field IDs are unclear. The example uses names like "node-input-username" but then explains that the same ID conventions as for regular node properties are used, which are different. That would be "node-config-input-username" here.

I'll ignore number 1 for now. After fixing number 2 and changing my field IDs to include "config", the flow cred .json file is larger than before and the editor fields show the values I entered before. So the documentation example is wrong. Bug found on Node-RED side.

The note about password fields not being accessible easily in the editor is also wrong, but that didn't cause any work on my side. Password fields are already set appropriately. Not with the actual password of course, but with a recognisable placeholder. So no work is necessary for this. Password fields just work.

Lots of nodes use the credentials feature? I'm wondering how they figured out how it works. I'm using Node-RED version 0.20.0 by the way, that should be the latest release as of today.

As this is an open source project I'm sure we would all appreciate a pull request to improve the documentation.

Latest version of Node-RED is listed on the home page and is currently v.0.20.1

Yes they do. They seem to have worked it out without aggressive posts in the forum.

Please, as ukmoose says, clone the docs repo, do an update and submit a PR so that they are improved.

If you follow the documentation you will have a working system. So it is entirely possible you've misinterpreted what you need to do. So saying you've followed the documentation doesn't actually tell us what you've done.

I'm sure there are improvements that could be made and we welcome constructive feedback, but none of the information is wrong.

No they are not. Point 1 is about adding that block to the node's definition in its HTML file - I acknowledge the point could be made clearer. Point 3 is about adding that block to the node's JavaScript file as part of its call to RED.nodes.registerType. You need both for this to work. If you've only done it in one place then it will not work.

So, instead of following the docs exactly as described, you've decided to ignore one of the steps.

This is why I asked to see what you had actually done so we could help spot the mistake.

I could be mistaken, but I think there actually are three places that credentials have to be mentioned, two in the .html file and one in the .js file. Obviously, the documentation could be more explicit, but I have to leave that to more experienced folks.

Yes I also use it in several of my custom nodes. It was rather easy to implement, after I had read the instructions on the page you are referring to.

That is not correct, like Nick already explained. Point 1 and 2 refer to the client side (.html), while point 3 refers to the server side (.js). That could indeed be added to the docs, so feel free to create a pull request.

Yes you can have a look at 21-httprequest.js and 21-httprequest.html. That was for me sufficient to get the job done...