influxdata / influxdb-python

Python client for InfluxDB
MIT License
1.7k stars 522 forks source link

Authorization error against InfluxDB 2.0 #897

Open rajahaidar opened 3 years ago

rajahaidar commented 3 years ago

When upgrading influxDB from 1.8 to 2.0, and trying to use the same application logic we currently have, we are getting a 401 unauthorized when trying to insert data using the admin user which was specified in the upgrade environment variables.

Error raised: 401: {"code":"unauthorized","message":"Unauthorized"}

This is the docker-compose that was used to bring up the instance

  influxdb:
    image: influxdb:2.0
    ports:
      - '8086:8086'
    volumes:
      - ./influxdb:/var/lib/influxdb
      - ./influxdb2:/var/lib/influxdb2

    networks:
      - backend
    environment:
      # - INFLUXDB_ADMIN_USER=admin
      # - INFLUXDB_ADMIN_PASSWORD=supersecret
      # - INFLUXDB_DB=db0
      - DOCKER_INFLUXDB_INIT_MODE=upgrade
      - DOCKER_INFLUXDB_INIT_USERNAME=admin
      - DOCKER_INFLUXDB_INIT_PASSWORD=supersecret
      - DOCKER_INFLUXDB_INIT_ORG=someorg
      - DOCKER_INFLUXDB_INIT_BUCKET=default
BaneOfKnoll commented 3 years ago

I'm also getting this in my unraid docker environment. Trying to set up with influxDB2.0 has there been any indication of a solution?

lestercollado commented 3 years ago

Help!

BaneOfKnoll commented 3 years ago

I found some info that indicates the issue I was having. Not sure if it also affects you. https://community.influxdata.com/t/getting-started-with-influxdb-docker-401-unauthorized/16989/3

raymond4entrak commented 2 years ago

I also come across a similar problem. Mine is running on a VM. I successfully updated from v1.8 to v2.2 on 31-May and operated as usual on 1-Jun. But today (2-Jun), it suddenly rejected all the requests with an unauthorized error. Now, I even can't run any influx command via the CLI.

Please help!

pspacek commented 2 years ago

InfluxDB v1 compatibility requires extra setup using influx v1 authorization create command. InfluxDB v2 API is provided by different library: https://influxdb-client.readthedocs.io/en/stable/index.html

Pick your poison, I would day.