Documentation

Manage tokens

Manage tokens to authenticate and authorize access to server actions, resources, and data in your InfluxDB 3 Core instance.

Provide your token

If you start the InfluxDB 3 Core server with authentication enabled (the default), future server actions (CLI commands and HTTP API requests) require a valid token for authorization.

The first admin token you create is the operator token (named _admin), which has full administrative privileges. You can use the operator token to authenticate your requests and manage additional authorization tokens.

The mechanism for providing your token depends on the client you use to interact with InfluxDB 3 Core–for example:

When using the influxdb3 CLI, you can set the INFLUXDB3_AUTH_TOKEN environment variable to automatically provide your authorization token to all influxdb3 commands–for example:

# Export your token as an environment variable
export INFLUXDB3_AUTH_TOKEN=
YOUR_AUTH_TOKEN
# Run an influxdb3 command influxdb3 query \ --database DATABASE_NAME \ "SELECT * FROM 'DATABASE_NAME' WHERE time > now() - INTERVAL '10 minutes'"
  • Copy
  • Fill window

To specify a token in the command and override the environment variable, pass the --token option with your authorization token–for example:

# Include the --token option in your influxdb3 command
influxdb3 query \
  --token 
YOUR_AUTH_TOKEN
\
--database DATABASE_NAME \ "SELECT * FROM 'DATABASE_NAME' WHERE time > now() - INTERVAL '10 minutes'"
  • Copy
  • Fill window

You can also set the INFLUXDB3_AUTH_TOKEN environment variable to automatically provide your authorization token to all influxdb3 commands.

To authenticate directly to the HTTP API, you can include your authorization token in the HTTP Authorization header of your request. The Authorization: Bearer AUTH_TOKEN scheme works with all HTTP API endpoints that require authentication.

The following examples use curl to show to authenticate to the HTTP API.

# Add your token to the HTTP Authorization header
curl "http://localhost:8181/api/v3/query_sql" \
  --header "Authorization: Bearer 
AUTH_TOKEN
"
\
--data-urlencode "db=DATABASE_NAME" \ --data-urlencode "q=SELECT * FROM 'DATABASE_NAME' WHERE time > now() - INTERVAL '10 minutes'"
  • Copy
  • Fill window

Authenticate using v1 and v2 compatibility

InfluxDB 3 provides compatibility with InfluxDB v1 and v2 APIs, allowing you to use the same authentication methods as in those versions. With InfluxDB v1-compatible endpoints in InfluxDB 3, you can use database tokens in InfluxDB 1.x username and password scheme. With the InfluxDB v2-compatible /api/v2/write endpoint, you can use tokens in the InfluxDB v2 Authorization: Token scheme or in the OAuth Authorization: Bearer scheme.

The following examples show how to authenticate with the InfluxDB v1-compatible and v2-compatible APIs in InfluxDB 3:

# Token scheme with v2 /api/v2/write
curl http://localhost:8181/api/v2/write\?bucket\=DATABASE_NAME \
  --header "Authorization: Token 
AUTH_TOKEN
"
\
--data-raw "home,room=Kitchen temp=23.5 1622547800"
  • Copy
  • Fill window
# Basic scheme with v1 /write
# Username is ignored, but required for the request
# Password is your auth token encoded in base64
curl "http://localhost:8181/write?db=DATABASE_NAME" \
  --user "any:
AUTH_TOKEN
"
\
--data-raw "home,room=Kitchen temp=23.5 1622547800"
  • Copy
  • Fill window
# URL auth parameters with v1 /write
# Username is ignored, but required for the request
curl "http://localhost:8181/write?db=DATABASE_NAME&u=any&p=
AUTH_TOKEN
"
\
--data-raw "home,room=Kitchen temp=23.5 1622547800"
  • Copy
  • Fill window

Replace the following with your values:

  • AUTH_TOKEN: your token
  • DATABASE_NAME: the name of the database you want to query

To use tokens with other clients for InfluxDB 3 Core, see the client-specific documentation:


Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Read more

New in InfluxDB 3.2

Key enhancements in InfluxDB 3.2 and the InfluxDB 3 Explorer UI is now generally available.

See the Blog Post

InfluxDB 3.2 is now available for both Core and Enterprise, bringing the general availability of InfluxDB 3 Explorer, a new UI that simplifies how you query, explore, and visualize data. On top of that, InfluxDB 3.2 includes a wide range of performance improvements, feature updates, and bug fixes including automated data retention and more.

For more information, check out: