Cover the 1.0.0 command surface and stability guarantees: - New reference files: projects.md, runners.md, extensions.md - New commands: browse, project, runner, extension, upgrade, pr backport, pr update-branch, pr list --local, pr merge --method manually-merged, issue move, issue/pr comment attachment, webhook test - Global --csv output; exit codes 5 (run watch failed) and 6 (--expect-head) - Interactive edit forms for pr/label/release edit - Fix fork flag (--add-remote), clone flag (--upstream-remote-name), and org member subcommands (add -> conceal/publicize) - tea is archived; gt is the official successor; migration guide linked - Semver: 1.x keeps commands/flags/JSON fields/exit codes stable - Bump metadata/README to gt 1.0.0
4.0 KiB
auth (gt auth)
Authentication, accounts, git credential setup, and environment variables.
gt <cmd> --help is authoritative.
gt keeps accounts in hosts.yml and tokens in the system keyring (or a
private file), under ~/.config/gitea-cli/ (GITEA_CLI_CONFIG_DIR overrides).
It never reads tea's config. One account per instance is active; --user or
GITEA_CLI_USER selects another for a single command.
Commands
gt auth <command>
login logout refresh setup-git status switch token
login
Without a method flag on a terminal it asks for the instance, login method,
token storage and whether git should use gt.
| Flag | Meaning |
|---|---|
--with-token |
Read an access token from stdin (or ask on a terminal) |
--oauth |
Authorize in a browser; --client-id ID selects the OAuth app |
--scopes scopes |
OAuth scopes, e.g. read:repository,read:user (implies --oauth) |
--credential-store {keyring|file} |
Where to keep the token (default keyring) |
--insecure |
Skip TLS verification for this instance |
--header "Name: value" |
Send a header with every request (repeatable; $VAR expansion) |
--ssh-key file, --ssh-agent-key fp, --ssh-agent-principal p |
Sign requests with SSH |
--client-cert file, --client-key file |
TLS client certificate |
-y, --yes |
Replace an existing account without confirming |
gt auth login
gt auth login --host gitea.com --with-token < token.txt
gt auth login --host gitea.com --oauth --scopes read:repository,read:user
gt auth login --host g.example.com --with-token \
--header 'CF-Access-Client-Id: $CF_ID' --header 'CF-Access-Client-Secret: $CF_SECRET'
Create a token on the instance under Settings > Applications. The first
instance logged in to becomes default_host unless one is set.
status / token / switch / setup-git / logout / refresh
status [--verify] [--json ...]— accounts per instance, active one, method. Fails with exit 4 when there is no account or the credential is missing/rejected, and 1 when--verifygets no answer; with--jsonit exits 0 either way, so readcredential_available,verified,error. JSON fields:active, credential_available, credential_store, error, expires_at, git_credential_helper, host, method, scopes, user, verified.token— print the active token (refreshing an expiring OAuth token). SSH-key accounts have no token.switch— change the active account of an instance.setup-git [--keep-helpers] [--local]— configure git to askgtfor credentials. Other credential helpers are turned off for the instance unless--keep-helpers;--localconfigures only the current repository.logout,refresh.
gt auth status --verify
gt auth status --host gitea.com --json
curl -H "Authorization: token $(gt auth token)" https://gitea.com/api/v1/user
Environment variables
GITEA_TOKEN+GITEA_INSTANCE_URL(orGITEA_CLI_HOST): use a token instead of stored credentials.GITEA_TOKENreplaces the active account of its instance for the active account too; it must belong to the account--user/GITEA_CLI_USERnames.- In Gitea Actions,
GITEA_TOKENis enough:gtpicks the instance from the job (GITEA_SERVER_URL), likeghon GitHub. GITEA_CLI_*prefixed variables mirror global flags and settings; seegt help environmentfor the full list (config dir, user, repo, editor, pager, color, http timeout, data dir, extensions, ...).GITEA_INSTANCE_INSECURE,GITEA_INSTANCE_SSH_HOST: pair withGITEA_TOKEN.
doctor
gt doctor [-R ...] [--json ...] checks the setup commands in this directory
use: settings files, the instance and its headers, whether it answers, the
account and credential, the repository, and git. Each problem names the command
that fixes it; gt doctor fails when a check fails. JSON fields: checks, host, host_source, repo, repo_source, user, user_source.
gt doctor
gt doctor -R gitea.com/gitea/cli
gt doctor --jq '.checks[] | select(.status == "failed")'