mblackstock / node-red-contrib-influxdb

Node-RED nodes to save and query data from an influxdb time series database
Other
64 stars 44 forks source link

Feature request: Support to configure the Token using an env var #109

Open cmoulliard opened 2 years ago

cmoulliard commented 2 years ago

Feature request

It is not possible for the moment to configure the token of an influxdb server using an ENV var

msg.token=env.get('INFLUXDB_TOKEN')
msg.url=env.get('INFLUXDB_URL')

node.log("Influxdb token: " + msg.token)
node.log("Influxdb url: " + msg.url)
-->
2 Dec 10:47:49 - [info] [function:To influxdb] Influxdb token: 5eCjcHxxxxxxx0iOXaMKCG8qVZanwMme0A==
2 Dec 10:47:49 - [info] [function:To influxdb] Influxdb url: http://localhost:80862 

as the influxdb out client will report the following error


ERROR: Write to InfluxDB failed. d [HttpError]: unauthorized access
    at IncomingMessage.<anonymous> (/Users/cmoullia/code/cmoulliard/node-red/flows/node_modules/@influxdata/influxdb-client/dist/index.js:16:10547)
    at IncomingMessage.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1317:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  statusCode: 401,
  statusMessage: 'Unauthorized',
  body: '{"code":"unauthorized","message":"unauthorized access"}',
  contentType: 'application/json; charset=utf-8',
  json: { code: 'unauthorized', message: 'unauthorized access' },
  code: 'unauthorized',
  _retryAfter: 0
}

Would it be possible to support such an option to set a node server property ?