bewee / node-red-contrib-webthingsio

https://www.npmjs.com/package/node-red-contrib-webthingsio
Mozilla Public License 2.0
1 stars 2 forks source link

Save accessToken as credentials #2

Open bewee opened 3 years ago

bewee commented 3 years ago

Credentials like the gateway access token should be saved separately: https://nodered.org/docs/creating-nodes/credentials.

However, the node red web app can only access text credentials in oneditprepare (and password credentials never), and the token is saved in the configuration node but required by the set/get/... nodes for fetching the gateway.

The only fix I could come up with is to rewrite the gateway fetching to take the indirection via a route on the node red server. There are some more benefits in this, namely it is an essential step for making the node red page of the webthings addon available through the tunnel, and also we would no longer have to perform the "dirty" check host == "localhost" to then use the document.hostname instead.