Authentication And Environments
Login flow
Section titled “Login flow”gaard login starts a browser-based sign-in flow, creates a personal access token, and stores that token in the CLI config.
gaard loginIf there is no current context and --api is omitted, the CLI defaults to:
https://app.gaard.ai/You can still target a different environment or assign a context name explicitly:
gaard login --api https://staging.gaard.ai --name stagingIf --name is omitted, the CLI derives the context name from the API hostname when possible.
When the command starts, it opens the verification URL in your browser if possible. If not, it prints the URL in the terminal so you can open it manually.
Config file
Section titled “Config file”By default, the CLI stores configuration at:
~/.gaard/config.yamlYou can override the location with the GAARD_CONFIG environment variable:
GAARD_CONFIG=/tmp/gaard.yaml gaard ctx listContexts
Section titled “Contexts”Contexts let you keep separate API URLs, tokens, and default tenants for different environments such as local, staging, and production.
List contexts:
gaard ctx listAdd a context without logging in yet:
gaard ctx add staging --api https://staging.gaard.aiSwitch the active context:
gaard ctx use stagingRemove a context:
gaard ctx remove stagingTenant selection
Section titled “Tenant selection”Tenant resolution follows this order:
--tenant- The context’s
session-tenant - The context’s default
tenant
If none is set, tenant-aware commands return an error telling you to select a tenant or pass --tenant.
Super users can switch the session tenant without re-authenticating:
gaard tenant listgaard tenant use acme_prodgaard tenant clearFor one-off commands, it is often simpler to override the tenant inline:
gaard --tenant acme_prod whoamiLogout
Section titled “Logout”gaard logout removes the stored token from the current context:
gaard logoutThe context remains in the config file, but authenticated commands will fail until you log in again.