th auth

Sign the CLI in and out, see who it acts as, and log Docker in to your Project’s container registry.

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

  1. Run th auth login --no-browser on the server.
  2. Open the printed link on any computer or phone where you are signed in to the Console.
  3. Check that the code matches and click Approve. The server’s terminal finishes signing in.

Push your own image with Docker

  1. Run th auth configure-docker. It logs Docker in to your Project’s registry.
  2. Tag and push the image to <host>/<project-slug>/<repository>.
  3. Deploy it with th container deploy NAME --image ….
Shell
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.4

Commands

CommandDescription
th auth loginSigns in with your ThailandHosting account.
th auth statusShows who the CLI acts as (also: th auth whoami, th whoami).
th auth logoutSigns this CLI token out on the server and removes it from the config file.
th auth print-access-tokenPrints the token the CLI sends (TH_API_KEY, TH_TOKEN or the saved login).
th auth configure-dockerLogs 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

Shell
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

Shell
th auth login

Only print the link (a server without a desktop)

Shell
th auth login --no-browser

Parameters

NameTypeDefaultDescription
--no-browserflagDo not try to open a browser; just print the link

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th auth status

Shows who the CLI acts as (also: th auth whoami, th whoami).

Also available as th whoami, th auth whoami

Syntax

Shell
th auth status

Examples

Show who the CLI acts as

Shell
th auth status

The same, as JSON

Shell
th whoami --format json

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th auth logout

Signs this CLI token out on the server and removes it from the config file.

Syntax

Shell
th auth logout

Examples

Sign this CLI out

Shell
th auth logout

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th auth print-access-token

Prints the token the CLI sends (TH_API_KEY, TH_TOKEN or the saved login).

Syntax

Shell
th auth print-access-token

Examples

Call the API with the CLI’s token

Shell
curl -H "Authorization: Bearer $(th auth print-access-token)" https://cloud.thailandhosting.com/api/v1/projects

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

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

Shell
th auth configure-docker

Examples

Log Docker in to the Project’s registry

Shell
th auth configure-docker

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑