Description
Signs you in to GitHub and saves the token, so that grit push, grit fetch and grit clone work with private repositories over HTTPS.
grit auth uses GitHub's device flow. It prints a web address and a short code. Open https://github.com/login/device in your browser, enter the code and approve access. grit waits until you do, then saves the token with your credential helper. Every request goes straight to github.com.
A credential helper has to be configured to store the token. On Windows, if none is set, grit uses its built-in one (grit manager). Elsewhere, set one with grit config:
$ grit config --global credential.helper osxkeychain # macOS
$ grit config --global credential.helper libsecret # Linux
$ grit config --global credential.helper store # a plain-text file, any system
grit auth logout removes the saved GitHub token from your credential helper.
grit signs in with its own GitHub OAuth app. To use a different one, set its client id in the GRIT_GITHUB_CLIENT_ID environment variable or the grit.githubClientId setting.
Options
| Option | Description |
|---|---|
logout |
Remove the saved GitHub token. |
JSON output
Pass --json for stable, scripting-friendly output:
| Field | Type | Meaning |
|---|---|---|
authenticated |
boolean | For sign-in, whether a token was stored. |
logged_out |
boolean | For logout, whether a stored token was removed. |
host |
string | GitHub host the credential applies to (usually github.com). |
logged_out is false when no credential helper is configured, since there's nowhere a token could be stored.