Knowledgebase

Authenticating with cloud service from k6


Purpose

Explanation of the different ways that you can log into Load Impact’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 Load Impact cloud service, whether it’s for streaming results or running tests in the cloud, you’ll need to authenticate. You can login with your Load Impact 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 Load Impact 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 Load Impact account credentials is not appropriate you can choose to enter your Load Impact 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 Load Impact API authentication token via environment variables. If you make sure the K6_CLOUD_TOKEN has been set to your Load Impact API authentication token k6 will pick it up when executing.

Using config file

You can also directly add your Load Impact 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 Load Impact 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