I'm unable to workaround an unauthorized response from InfluxDB 2 when using the 1.x write endpoint.
The setup:
From the InfluxDB 2.0 docs, it states it has some 1.x compatibility:
The InfluxDB v2 API includes InfluxDB 1.x compatibility endpoints that work with InfluxDB 1.x client libraries and third-party integrations like Grafana and others.
Spefically, /write is listed as 1.x compatible
So let's test this and write to a 2.0 server with 1.x api. First we'll spin up a docker image with a username and password
docker run -p 8086:8086 \
-e DOCKER_INFLUXDB_INIT_MODE=setup \
-e DOCKER_INFLUXDB_INIT_USERNAME=my-user \
-e DOCKER_INFLUXDB_INIT_PASSWORD=my-password \
-e DOCKER_INFLUXDB_INIT_ORG=myorg \
-e DOCKER_INFLUXDB_INIT_BUCKET=mydb \
influxdb:2.0
The docs state that we can authenticate with basic authentication, so the following example (also from their docs with only the authentication switched to curl's more ergonomic --user option) should work:
curl -v --request POST http://localhost:8086/write?db=mydb \
--user my-user:my-password \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
Unfortunately a 401 is returned with the following payload:
{"code":"unauthorized","message":"Unauthorized"}
What could be the issue? I'm providing the minimum number of required arguments in the docker setup and I've copied and pasted the example from their docs -- there aren't too many areas where it could go wrong.
The endgoal is to have a single client that can write to both 1.x and 2.x as some deployments are 1.x and others are 2.x. Reading the docs make me think this is possible, but following the docs makes me think otherwise. Is the solution really to embed both InfluxDB 1.x and 2.x clients and require users to specify this version before running the app?
Fwiw, adding more verbose logging doesn't yield additional insight -- only the same unauthorized line:
docker run -p 8086:8086 \
-e DOCKER_INFLUXDB_INIT_MODE=setup \
-e DOCKER_INFLUXDB_INIT_USERNAME=my-user \
-e DOCKER_INFLUXDB_INIT_PASSWORD=my-password \
-e DOCKER_INFLUXDB_INIT_ORG=myorg \
-e DOCKER_INFLUXDB_INIT_BUCKET=mydb \
-e INFLUXD_LOG_LEVEL=debug \
influxdb:2.0