choes
choes

Reputation: 311

InfluxDB reports "unauthorized access" with the generated token

I downloaded the latest version of InfluxDB, it's influxdb2-2.0.3_darwin_amd64. I want to write data to the InfluxDB, and followed the documentation of "Use InfluxDB API". I got the "unauthorized access" message.

 curl --request POST "http://localhost:8086/api/v2/write?org=9682c3eaabb5384c&bucket=test_bucket&precision=s" \
 --header "Authorizations: TOKEN _XHOou59351P2Y8JjVDRWNMN22phTUzDVpUJtN85Dby6rfKSjDmGnxWTS_CbjZj-TJn7EaEduDwgtQyOY3BUeg==" \
 --data-raw "mem,host=host1 used_percent=23.43234543 1556896326"

{"code":"unauthorized","message":"unauthorized access"}

The token was copied from the web UI. enter image description here

Could anyone help me to solve this authentication problem? Thanks in advance.

Upvotes: 2

Views: 20788

Answers (2)

Hasan Isalou
Hasan Isalou

Reputation: 11

Try this

`curl --request POST  http://localhost:8086/api/v2/query?org=yourOrgName --header 'Authorization: Token tokenValue' --header 'Accept: application/csv' --header 'Content-type: application/vnd.flux' --data 'from(bucket:"BucketName") |> range(start: 0)|> filter(fn: (r) => r["_measurement"] == "MeasurementName")'`

Upvotes: -1

choes
choes

Reputation: 311

I didn't follow the documentation exactly, it's case sensitive. It's "Token", not "TOKEN".

--header "Authorization: Token YOURAUTHTOKEN"

Upvotes: 11

Related Questions