# getCredentials not being called

**URL:** <https://discourse.nodered.org/t/getcredentials-not-being-called/54567>\
**Category:** General\
**Created:** [1 December 2021 12:15 UTC](https://discourse.nodered.org/t/getcredentials-not-being-called/54567 "2021-12-01T12:15:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hammoaj](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hammoaj/32/1998_2.png) [@hammoaj](https://discourse.nodered.org/u/hammoaj)\
**Post date:** [1 December 2021 12:15 UTC](https://discourse.nodered.org/t/getcredentials-not-being-called/54567/1 "2021-12-01T12:15:52Z")

</div>

I am in the process of re-implementing the `cloudantStorage` code that was originally written for IBM Cloud to use the new Cloudant SDK. It's mainly working, but I'm having problems with flow encryption.

To do this, I am implementing the Storage API. The first time I run Node-RED with Cloudant Storage enabled it creates the database as expected and creates and saves the flow credential. The problem I get is that when I stop and re-run Node-RED it fails to load the previously saved credentials with a syntax error. However, I have put a console log into the new `getCredentials` function and it's not even being called. Is it possible that there's a problem in the core which is causing this?

Clearly the standard local filesystem storage works fine, it just seems to appear when there's a pluggable storage module added.

I am looking in `@node-red/runtime/lib/storage/index.js` and it appears to me that the call for `getCredentials` is commented out from `StorageModuleInterface`. Is this correct @knolleary ?

Any ideas?

---

<div class="post-metadata">

**Author:** ![hammoaj](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hammoaj/32/1998_2.png) [@hammoaj](https://discourse.nodered.org/u/hammoaj)\
**Post date:** [2 December 2021 10:35 UTC](https://discourse.nodered.org/t/getcredentials-not-being-called/54567/2 "2021-12-02T10:35:09Z")

</div>

After further investigation, it appears that if `credentialSecret` is set to anything (`false` or your own choice of secret) then it works (and doesn't try to store a credentials document in the database). It's only if you let NR choose the default that you get the error.

@knolleary any idea whether is likely to be an error in my code or a bug somewhere in the core?

---

<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:** [2 December 2021 12:21 UTC](https://discourse.nodered.org/t/getcredentials-not-being-called/54567/3 "2021-12-02T12:21:47Z")

</div>

> [@hammoaj](#):
>
> I am looking in `@node-red/runtime/lib/storage/index.js` and it appears to me that the call for `getCredentials` is commented out from `StorageModuleInterface` . Is this correct @knolleary ?

You are looking at the api layer between the internal storage system and the main runtime. There is not a one-to-one mapping between the internal api and the Storage Plugin API.

Internally, the runtime calls `getFlows` of the storage layer and that is expected to return both flows and credential objects. Internally, the storage layer calls the Storage Plugin's `getFlows` and `getCredentials` to assemble the proper response. See [node-red/packages/node\_modules/@node-red/runtime/lib/storage/index.js at master · node-red/node-red · GitHub](https://github.com/node-red/node-red/blob/master/packages/node_modules/@node-red/runtime/lib/storage/index.js#L75) for details.

> [@hammoaj](#):
>
> fails to load the previously saved credentials with a syntax error.

Could you share the details of the syntax error?

If you were updating [node-red-app/cloudantStorage.js at master · IBM/node-red-app · GitHub](https://github.com/IBM/node-red-app/blob/master/cloudantStorage.js) to use the new SDK library under the covers, I don't see why you'd get different behaviours in the Node-RED \<--\> plugin interaction.

---

<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:** [31 January 2022 12:21 UTC](https://discourse.nodered.org/t/getcredentials-not-being-called/54567/4 "2022-01-31T12:21:58Z")

</div>

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