Knowledgebase

How to Authenticate Against the LoadImpact Cloud With k6


Purpose

Explanation of the different ways that you can log into LoadImpact’s cloud service from k6 for the purpose of running tests locally and streaming results to Insights or running cloud executed tests.

Authenticating using email/password

Before you can interact with the LoadImpact cloud service, whether it’s for streaming results or running tests in the cloud, you’ll need to authenticate. You can login with your LoadImpact email/password credentials by entering the following command into your terminal:

k6 login cloud

This will login to your account, fetch (and create of necessary) your LoadImpact API authentication token, and save it to a k6 configuration file.

Authenticating using API authentication token

If you’re a Google/Github Single Sign-On (SSO) user or if you have a use case where using your LoadImpact account credentials is not appropriate you can choose to enter your LoadImpact API authentication token directly by entering the following command into your terminal:

k6 login cloud --token YOUR_API_AUTH_TOKEN

Using environment variables

You can also authenticate with your LoadImpact API authentication token via environment variables. If you make sure the K6_CLOUD_TOKEN has been set to your LoadImpact API authentication token k6 will pick it up when executing.

Using config file

You can also directly add your LoadImpact API authentication token to a configuration file. Either in the default path that k6 will look for it by default:

${HOME}/.config/loadimpact/k6/config.json
${HOME}/Library/Application Support/LoadImpact/k6/config.json
C:\Users\<User>\AppData\Roaming\loadimpact\k6\config.json

or by specifying the -c/--config PATH/TO/CONFIG_FILE CLI flag.

When your LoadImpact API authentication token has been added to the config file, it should look something like this (removing any other config options from the file):

1
2
3
4
5
6
7
{
    "collectors" {
        "cloud": {
            "token": "YOUR_API_AUTH_TOKEN"
        }
    }
}

See also