About
th auth login uses a device code: the CLI shows a code, you approve it in the Console, and the CLI receives a token that lasts 90 days. Each sign-in is listed under Account → Sessions in the Console.
Instead of signing in, CI and scripts can set TH_API_KEY (an API key) or TH_TOKEN. These take precedence over the saved sign-in; see Environment variables.
How-to guides
Sign in on a server without a browser
- Run
th auth login --no-browseron the server. - Open the printed link on any computer or phone where you are signed in to the Console.
- Check that the code matches and click Approve. The server’s terminal finishes signing in.
Push your own image with Docker
- Run
th auth configure-docker. It logs Docker in to your Project’s registry. - Tag and push the image to
<host>/<project-slug>/<repository>. - Deploy it with
th container deploy NAME --image ….
th auth configure-docker
docker build -t registry.thailandhosting.com/my-project/api:1.4 .
docker push registry.thailandhosting.com/my-project/api:1.4
th container deploy api --image registry.thailandhosting.com/my-project/api:1.4Commands
| Command | Description |
|---|---|
th auth login | Signs in with your ThailandHosting account. |
th auth status | Shows who the CLI acts as (also: th auth whoami, th whoami). |
th auth logout | Signs this CLI token out on the server and removes it from the config file. |
th auth print-access-token | Prints the token the CLI sends (TH_API_KEY, TH_TOKEN or the saved login). |
th auth configure-docker | Logs Docker in to the Project's container registry, so docker push and docker pull work with <host>/<project-slug>/<repository>. |
th auth login
Signs in with your ThailandHosting account.
Syntax
th auth login [--no-browser]The CLI shows a code and opens the Console in your browser; approve the code there. The token is saved in the th config file and lasts 90 days.
Examples
Sign in; opens the Console to approve the code
th auth loginOnly print the link (a server without a desktop)
th auth login --no-browserParameters
| Name | Type | Default | Description |
|---|---|---|---|
--no-browser | flag | Do not try to open a browser; just print the link |
Global parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th auth status
Shows who the CLI acts as (also: th auth whoami, th whoami).
Also available as th whoami, th auth whoami
Syntax
th auth statusExamples
Show who the CLI acts as
th auth statusThe same, as JSON
th whoami --format jsonGlobal parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th auth logout
Signs this CLI token out on the server and removes it from the config file.
Syntax
th auth logoutExamples
Sign this CLI out
th auth logoutGlobal parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th auth print-access-token
Prints the token the CLI sends (TH_API_KEY, TH_TOKEN or the saved login).
Syntax
th auth print-access-tokenExamples
Call the API with the CLI’s token
curl -H "Authorization: Bearer $(th auth print-access-token)" https://cloud.thailandhosting.com/api/v1/projectsGlobal parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.
th auth configure-docker
Logs Docker in to the Project's container registry, so docker push and docker pull work with <host>/<project-slug>/<repository>.
Syntax
th auth configure-dockerExamples
Log Docker in to the Project’s registry
th auth configure-dockerGlobal parameters
This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.