Skip to content

Commit bc0430a

Browse files
authored
Merge pull request #6069 from influxdata/6056-fix-auth-token-env-var-docs
Clarify token usage and add CLI/HTTP auth examples
2 parents d807505 + 8804b13 commit bc0430a

File tree

2 files changed

+70
-4
lines changed

2 files changed

+70
-4
lines changed
Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,66 @@
1-
Manage tokens to authenticate and authorize access to resources and data in your
2-
{{< product-name >}} instance.
1+
Manage tokens to authenticate and authorize access to resources and data in your {{< product-name >}} instance.
2+
3+
## Provide your token
4+
5+
Before running CLI commands or making HTTP API requests, you must provide a valid token to authenticate.
6+
The mechanism for providing your token depends on the client you use to interact with {{% product-name %}}--for example:
7+
8+
{{< tabs-wrapper >}}
9+
10+
{{% tabs %}}
11+
[influxdb3 CLI](#influxdb3-cli-auth)
12+
[cURL](#curl-auth)
13+
{{% /tabs %}}
14+
15+
{{% tab-content %}}
16+
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" %}}
33+
```bash
34+
# Export your token as an environment variable
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'"
41+
```
42+
{{% /code-placeholders %}}
43+
44+
Replace `YOUR_TOKEN` with your authorization token.
45+
46+
{{% /tab-content %}}
47+
48+
{{% tab-content %}}
49+
50+
{{% code-placeholders "AUTH_TOKEN" %}}
51+
```bash
52+
# Add your token to the HTTP Authorization header
53+
curl "http://{{< influxdb/host >}}/api/v3/query_sql" \
54+
--header "Authorization: Bearer AUTH_TOKEN" \
55+
--data-urlencode "db=example-db" \
56+
--data-urlencode "q=SELECT * FROM 'example-table' WHERE time > now() - INTERVAL '10 minutes'"
57+
```
58+
{{% /code-placeholders %}}
59+
60+
Replace `AUTH_TOKEN` with your actual InfluxDB 3 token.
61+
62+
{{% /tab-content %}}
63+
64+
{{< /tabs-wrapper >}}
365

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

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ data and resources in your InfluxDB 3 instance.
88
> Token metadata includes the hashed token string.
99
> InfluxDB 3 does not store the raw token string.
1010
11-
In the following examples, replace {{% code-placeholder-key %}}`AUTH_TOKEN`{{% /code-placeholder-key %}} with your InfluxDB {{% token-link "admin" %}}
12-
{{% show-in "enterprise" %}} or a token with read permission on the `_internal` system database`{{% /show-in %}}.
11+
> [!Important]
12+
> #### Required permissions
13+
>
14+
> Listing admin tokens requires a valid InfluxDB {{% token-link "admin" %}}{{% show-in "enterprise" %}} or a token with read access to the `_internal` system database{{% /show-in %}}.
15+
> For more information about providing a token, see [provide your token](/influxdb3/version/admin/tokens/#provide-your-token).
16+
1317

1418
## List all tokens
1519

0 commit comments

Comments
 (0)