Skip to content

Commit 956659c

Browse files
MeelahMesanderson
andauthored
Update content/shared/influxdb3-admin/tokens/_index.md
Co-authored-by: Scott Anderson <[email protected]>
1 parent a79851d commit 956659c

File tree

1 file changed

+38
-15
lines changed
  • content/shared/influxdb3-admin/tokens

1 file changed

+38
-15
lines changed

content/shared/influxdb3-admin/tokens/_index.md

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,64 @@ Manage tokens to authenticate and authorize access to resources and data in your
55
Before running CLI commands or making HTTP API requests, you must provide a valid token to authenticate.
66
The mechanism for providing your token depends on the client you use to interact with {{% product-name %}}--for example:
77

8-
{{< code-tabs-wrapper >}}
8+
{{< tabs-wrapper >}}
99

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 %}}
1414

15-
{{% code-tab-content %}}
15+
{{% tab-content %}}
1616

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" %}}
1833
```bash
1934
# 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'"
2141
```
2242
{{% /code-placeholders %}}
2343

24-
Replace `your-token` with your actual InfluxDB 3 token.
44+
Replace `YOUR_TOKEN` with your authorization token.
2545

26-
{{% /code-tab-content %}}
46+
{{% /tab-content %}}
2747

28-
{{% code-tab-content %}}
48+
{{% tab-content %}}
2949

30-
{{% code-placeholders "your-token" %}}
50+
{{% code-placeholders "AUTH_TOKEN" %}}
3151

3252
```bash
3353
# 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'"
3558
```
3659

3760
{{% /code-placeholders %}}
3861

3962
Replace `your-token` with your actual InfluxDB 3 token.
4063

41-
{{% /code-tab-content %}}
64+
{{% /tab-content %}}
4265

43-
{{< /code-tabs-wrapper >}}
66+
{{< /tabs-wrapper >}}
4467

4568
{{< children hlevel="h2" readmore=true hr=true >}}

0 commit comments

Comments
 (0)