Javascript library 401 Unauthorized : {"error":"unable to parse authentication credentials"}

Hello!

I’m trying to run the examples from GitHub - influxdata/influxdb-client-js: InfluxDB 2.0 JavaScript client and I’m constantly getting a 401 when trying to run the query.ts example

I did the following:

  • enabled authentication via config (this is working fine with CURL)
  • created a user with all privileges
  • additionally granted all privileges on “my-bucket” to the user
  • Generate a JWT token

when I run the example I get

d [HttpError]: 401 Unauthorized : {“error”:“unable to parse authentication credentials”}

at IncomingMessage.<anonymous> (/home/paul/Documents/3rd_party_repos/influxdb-client-js/examples/node_modules/@influxdata/influxdb-client/src/impl/node/NodeHttpTransport.ts:246:13)
at IncomingMessage.emit (events.js:326:22)
at IncomingMessage.EventEmitter.emit (domain.js:483:12)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {

statusCode: 401,
statusMessage: ‘Unauthorized’,
body: ‘{“error”:“unable to parse authentication credentials”}\n’,
contentType: ‘application/json’,
json: { error: ‘unable to parse authentication credentials’ },
code: undefined,
_retryAfter: 0
}

any suggestions on how to debug this issue?

Hello @pablo,
Thank you. @bednar can you please help with this? Thank you.

Hello @pablo,

It seems to me that you are running the query.ts example against InfluxDB v1. So please either setup INFLUX_URL to point to InfluxDB 2.x instance or follow the influxdb-1.8.ts example.

1 Like