Before you can interact with the k6 Cloud service, whether it's for streaming results or running tests in the cloud, you'll need to authenticate. Your Auth Token is what enables this and allows you to interact with the k6 Cloud using the k6 CLI or through the REST API. To get your Auth Token, please visit this page.
Below are some examples on how to utilize the token to authenticate.
Google/GitHub Single Sign-On Users
For Single Sign-On (SSO) users, k6 login cloud requires a k6 cloud account email and password. You will need to create a password by using Forgot Password, or you'll instead need to get your API authentication token from the app and supply that explicitly: k6 login cloud --token YOUR_API_AUTH_TOKEN.See below for more information.
If you're running k6 in a Docker container you'll need to make sure that the k6 config file where the k6 cloud API authentication information (an API authentication token) will be stored to is persisted via a Docker volume to the host machine using the -c/--config PATH/TO/CONFIG_FILE CLI flag, e.g. docker run -i -v /path/on-host:/path/in-container/ loadimpact/k6 login cloud -c /path/in-container/config.json.
Integrating with CI
If you are integrating k6 into your CI pipeline, we recommend using one of the token methods to authenticate and not exposing your username/password within your CI configuration files or as variables.
You can forego using a token and use your k6 cloud email/password credentials by entering the following command into your terminal:
This will login to your account, fetch (and create of necessary) your k6 cloud API authentication token, and save it to a k6 configuration file.
If you're a Google/GitHub Single Sign-On (SSO) user or if you have a use case where using your k6 cloud account credentials is not appropriate you can choose to enter your k6 cloud API authentication token directly by entering the following command into your terminal:
You can also authenticate with your k6 cloud API authentication token via environment variables. If you make sure the K6_CLOUD_TOKEN has been set to your k6 cloud API authentication token k6 will pick it up when executing.
You can also directly add your k6 cloud API authentication token to a configuration file. Either in the default path that k6 will look for it by default:
or by specifying the -c/--config PATH/TO/CONFIG_FILE CLI flag.
When your k6 cloud API authentication token has been added to the config file, it should look something like this (removing any other config options from the file):