Skip to main content
1

Start the login

Run the login command in your terminal:
The CLI shows a short code and opens the authorization page in your browser.
2

Approve in the browser

Type the code on the page and approve. The CLI receives its own API key, no copy and paste needed, and saves it on this machine.
Output
A key issued this way has only the permissions the CLI’s commands use, including blob:read and blob:write for the blob commands, and expires after 90 days. auth whoami shows the date; run squarecloud auth login again to renew it. The key is saved in the system keychain: Windows Credential Manager, the macOS Keychain, or the Secret Service on Linux (GNOME Keyring, KWallet). Where there is none (containers, WSL without D-Bus), it stays in a config.json file readable only by you, and auth login says so: in %APPDATA%\Square Cloud CLI on Windows, and in $XDG_CONFIG_HOME/squarecloud or ~/.config/squarecloud on macOS and Linux. A key that an older version saved in that file moves to the keychain the next time it is used.

squarecloud auth login

Usage
Output with an API key
  • Press Ctrl+C to cancel a login that is waiting for approval.
  • If this machine is already logged in to another account, auth login asks before replacing it. Pass -y to skip the question.
  • If your account has reached its API key limit, the browser login says so and continues on its own as soon as you revoke a key in the dashboard.
  • Without a terminal, the command doesn’t prompt: it exits with a hint. With CI=true, the browser login refuses to run. See CI and scripts.

squarecloud auth whoami

Usage
Shows the account you are logged in as, its plan and how many days are left before the plan expires. For a key issued by the browser login, it also shows when the key expires and its scopes; when the key comes from SQUARECLOUD_API_KEY, it says so instead.
Output
With --json, it prints the account (ID, name, email, locale, plan and creation date) as JSON.

squarecloud auth logout

Usage
Removes the saved API key from this machine, from both the keychain and the config file. It doesn’t revoke the key: to do that, delete it in the dashboard. When SQUARECLOUD_API_KEY is set, commands keep using it after a logout.
Output
When no account is connected, it prints No account is connected on this machine. and exits with code 0.

Several accounts

--profile <name>, or the SQUARECLOUD_PROFILE environment variable, picks a separate login with its own keychain entry. Without either, the CLI uses the default profile. A profile name has 1 to 32 letters, digits, - or _, and starts with a letter or digit.
auth login and auth whoami name the profile when it isn’t the default one. SQUARECLOUD_API_KEY, when set, wins over every profile.

CI and scripts

In CI, don’t log in at all: create an API key in the dashboard and set it in the SQUARECLOUD_API_KEY environment variable. Every command uses it instead of the saved key, and the CLI runs even on machines without a home folder.
  • Without a terminal, auth login doesn’t prompt for anything: it exits with a hint. Use --with-token, --token or SQUARECLOUD_API_KEY.
  • With CI=true, the browser login refuses to run, since its key expires in 90 days and only a person can renew it.
  • For the blob commands, the key needs the blob:read and blob:write scopes.
More on exit codes and JSON output in Global flags and CI.

When the key stops working

If a command says your session expired or the API key was revoked, run squarecloud auth login again. Do the same when it says the key doesn’t have the permission the command needs (MISSING_SCOPE): a key from a browser login before version 3.2.0 lacks the Blob scopes, and the new login issues a key that has them. Commands that need an account print You need to be logged in to run this command. and exit with code 1 when no key is saved or set.