InfluxDB - 未授权访问问题

问题描述 投票:0回答:0

我是 InfluxDB 的新手,在尝试使用 Python influxdb 库连接到我的 InfluxDB 实例时遇到“未经授权的访问”问题。我收到以下错误消息: 原因:未经授权

HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json; charset=utf-8', 'X-Influxdb-Build': 'OSS', 'X-Influxdb-Version': 'v2.7.0', 'X-Platform-Error-Code': 'unauthorized', 'Date': 'Wed, 17 May 2023 15:03:50 GMT', 'Content-Length':  '55'}) HTTP response body: {"code":"unauthorized","message":"unauthorized access"}

我尝试从 InfluxDB 文档中尝试使用 python 客户端库进行连接的代码片段,是为了熟悉这个过程:

 import influxdb_client, os, time
 from influxdb_client import InfluxDBClient, Point, WritePrecision
 from influxdb_client.client.write_api import SYNCHRONOUS

 token = os.environ.get("INFLUXDB_TOKEN")
 org = "Org_Name"
 url = "http://localhost:8086"

 write_client = influxdb_client.InfluxDBClient(url=url, token=token, org=org)

 bucket="SensorDB"

 write_api = write_client.write_api(write_options=SYNCHRONOUS)
   
 for value in range(5):
   point = (
     Point("measurement1")
     .tag("tagname1", "tagvalue1")
     .field("field1", value)
   )
   write_api.write(bucket=bucket, org="Org_Name", record=point)
   time.sleep(1) # separate points by 1 second

此错误的原因可能是什么,我该如何解决?

任何指导或建议将不胜感激。谢谢!

your text

python-3.x influxdb influxdb-python
© www.soinside.com 2019 - 2024. All rights reserved.