Authentication

Use one of the following schemes to authenticate to the InfluxDB Cloud Serverless API:

  • Token authentication
  • Basic authentication

Basic Authentication

Basic authentication scheme

Use the HTTP Basic authentication scheme for InfluxDB /api/v2 API operations that support it:

Syntax

Authorization: Basic BASE64_ENCODED_CREDENTIALS

To construct the BASE64_ENCODED_CREDENTIALS, combine the username and the password with a colon (USERNAME:PASSWORD), and then encode the resulting string in base64. Many HTTP clients encode the credentials for you before sending the request.

Warning: Base64-encoding can easily be reversed to obtain the original username and password. It is used to keep the data intact and does not provide security. You should always use HTTPS when authenticating or sending a request with sensitive information.

Examples

In the examples, replace the following:

  • EMAIL_ADDRESS: InfluxDB Cloud username (the email address the user signed up with)
  • PASSWORD: InfluxDB Cloud API token
  • INFLUX_URL: your InfluxDB Cloud URL

Encode credentials with cURL

The following example shows how to use cURL to send an API request that uses Basic authentication. With the --user option, cURL encodes the credentials and passes them in the Authorization: Basic header.

curl --get "INFLUX_URL/api/v2/signin"
    --user "EMAIL_ADDRESS":"PASSWORD"

Encode credentials with Flux

The Flux http.basicAuth() function returns a Base64-encoded basic authentication header using a specified username and password combination.

Encode credentials with JavaScript

The following example shows how to use the JavaScript btoa() function to create a Base64-encoded string:

btoa('EMAIL_ADDRESS:PASSWORD')

The output is the following:

'VVNFUk5BTUU6UEFTU1dPUkQ='

Once you have the Base64-encoded credentials, you can pass them in the Authorization header–for example:

curl --get "INFLUX_URL/api/v2/signin"
    --header "Authorization: Basic VVNFUk5BTUU6UEFTU1dPUkQ="

To learn more about HTTP authentication, see Mozilla Developer Network (MDN) Web Docs, HTTP authentication._

Token Authentication

Use the Token authentication scheme to authenticate to the InfluxDB API.

In your API requests, send an Authorization header. For the header value, provide the word Token followed by a space and an InfluxDB API token. The word Token is case-sensitive.

Syntax

Authorization: Token INFLUX_API_TOKEN

Example

Use Token authentication with cURL

The following example shows how to use cURL to send an API request that uses Token authentication:

curl --request GET "INFLUX_URL/api/v2/buckets" \
     --header "Authorization: Token INFLUX_API_TOKEN"

Replace the following:

  • /authorizations endpoints)

Was this page helpful?

Thank you for your feedback!