@@ -5,41 +5,64 @@ Manage tokens to authenticate and authorize access to resources and data in your
5
5
Before running CLI commands or making HTTP API requests, you must provide a valid token to authenticate.
6
6
The mechanism for providing your token depends on the client you use to interact with {{% product-name %}}--for example:
7
7
8
- {{< code- tabs-wrapper >}}
8
+ {{< tabs-wrapper >}}
9
9
10
- {{% code- tabs %}}
11
- [ CLI] ( #cli-auth )
12
- [ HTTP API ] ( #http-api -auth )
13
- {{% /code- tabs %}}
10
+ {{% tabs %}}
11
+ [ influxdb3 CLI] ( #influxdb3- cli-auth )
12
+ [ cURL ] ( #curl -auth )
13
+ {{% /tabs %}}
14
14
15
- {{% code- tab-content %}}
15
+ {{% tab-content %}}
16
16
17
- {{% code-placeholders "your-token" %}}
17
+ When using the ` influxdb3 ` CLI, you can use the ` --token ` option to provide your authorization token.
18
+
19
+ {{% code-placeholders "YOUR_TOKEN" %}}
20
+ ``` bash
21
+ # Include the --token option in your influxdb3 command
22
+ influxdb3 query \
23
+ --token YOUR_TOKEN \
24
+ --database example-db \
25
+ " SELECT * FROM 'example-table' WHERE time > now() - INTERVAL '10 minutes'"
26
+ ```
27
+ {{% /code-placeholders %}}
28
+
29
+ You can also set the ` INFLUXDB3_AUTH_TOKEN ` environment variable to automatically provide your
30
+ authorization token to all ` influxdb3 ` commands.
31
+
32
+ {{% code-placeholders "YOUR_TOKEN" %}}
18
33
``` bash
19
34
# Export your token as an environment variable
20
- export INFLUXDB3_AUTH_TOKEN=your-token
35
+ export INFLUXDB3_AUTH_TOKEN=YOUR_TOKEN
36
+
37
+ # Run an influxdb3 command without the --token option
38
+ influxdb3 query \
39
+ --database example-db \
40
+ " SELECT * FROM 'example-table' WHERE time > now() - INTERVAL '10 minutes'"
21
41
```
22
42
{{% /code-placeholders %}}
23
43
24
- Replace ` your-token ` with your actual InfluxDB 3 token.
44
+ Replace ` YOUR_TOKEN ` with your authorization token.
25
45
26
- {{% /code- tab-content %}}
46
+ {{% /tab-content %}}
27
47
28
- {{% code- tab-content %}}
48
+ {{% tab-content %}}
29
49
30
- {{% code-placeholders "your-token " %}}
50
+ {{% code-placeholders "AUTH_TOKEN " %}}
31
51
32
52
``` bash
33
53
# Add your token to the HTTP Authorization header
34
- --header " Authorization: Bearer your-token"
54
+ curl " http://localhost:8181/api/v3/query_sql" \
55
+ --header " Authorization: Bearer AUTH_TOKEN" \
56
+ --data-urlencode " db=example-db" \
57
+ --data-urlencode " q=SELECT * FROM 'example-table' WHERE time > now() - INTERVAL '10 minutes'"
35
58
```
36
59
37
60
{{% /code-placeholders %}}
38
61
39
62
Replace ` your-token ` with your actual InfluxDB 3 token.
40
63
41
- {{% /code- tab-content %}}
64
+ {{% /tab-content %}}
42
65
43
- {{< /code- tabs-wrapper >}}
66
+ {{< /tabs-wrapper >}}
44
67
45
68
{{< children hlevel="h2" readmore=true hr=true >}}
0 commit comments