git-spice is offline-first.
It does not require authentication for local stacking operations.
However, once you want to push or pull changes to/from a remote repository,
you will need to authenticate with the respective service.
This page covers methods to authenticate git-spice with GitHub and GitLab.
Note that GitLab support requires at least version v0.9.0.
With OAuth authentication, you will take the following steps:
Authenticate yourself on the service website in your browser.
Authorize git-spice to act on your behalf on the current device only.
$ gs auth loginSelect an authentication method: OAuth1. Visit https://github.com/login/device2. Enter code: ABCD-1234The code expires in a few minutes.It will take a few seconds to verify after you enter it.
$ gs auth login
Select an authentication method: OAuth
1. Visit https://github.com/login/device
2. Enter code: ABCD-1234
The code expires in a few minutes.
It will take a few seconds to verify after you enter it.
On GitHub, OAuth is available in two flavors:
OAuth: grants access to all repositories, public and private.
OAuth: Public repositories only:
grants access to public repositories only.
For more granular control than that,
use GitHub App authentication.
Note
For private repositories owned by organizations,
you will need a member with administrative access to the repository
to allow installation of the git-spice OAuth App.
For Self-Hosted GitLab instances,
an administrator will need to set up a git-spice OAuth App.
Be sure to uncheck the "Confidential" option when creating the App.
With GitHub App authentication, you will take the following steps:
Authenticate yourself on github.com in your browser.
Authorize git-spice to act on your behalf on the current device only.
Install the git-spice GitHub App
on the repositories you want to use git-spice with.
$ gs auth loginSelect an authentication method: GitHub App1. Visit https://github.com/login/device2. Enter code: ABCD-1234The code expires in a few minutes.It will take a few seconds to verify after you enter it.
$ gs auth login
Select an authentication method: GitHub App
1. Visit https://github.com/login/device
2. Enter code: ABCD-1234
The code expires in a few minutes.
It will take a few seconds to verify after you enter it.
Important: Authentication alone does not grant any access.
You must install the GitHub App to access repositories with git-spice.
Note
For private repositories owned by organizations,
you will need a member with administrative access to the repository
to allow installation of the git-spice GitHub App.
If that is not an option,
use a Personal Access Token.
You can provide the authentication token as an environment variable.
This is not recommended as a primary authentication method,
but it can be useful in CI/CD environments.
Set the GITHUB_TOKEN environment variable to your token.
Set the GITLAB_TOKEN environment variable to your token.
If you have the environment variable set,
this takes precedence over all other authentication methods.
The gs auth login operation will always fail if you use this method.
OAuth is best if you have the permissions needed
to install it on all repositories that you want to use git-spice with.
Additionally, on GitHub, GitHub App is similar,
but it may be preferable if you don't want to give git-spice
access to all your repositories.
Service CLI is the most convenient method if you already have
the CLI for the service installed and authenticated,
and your organization already allows its use.
It loses security benefits of the other methods,
as it re-uses the token assigned to the CLI.
For example, it you lose the ability to revoke the git-spice token
without revoking the CLI token.
Personal Access Token is flexible and secure.
It may be used even with repositories where you don't have permission to
install OAuth or GitHub Apps.
However, it requires manual token management, making it less convenient.
Environment variable is the least convenient
and the least secure method. End users should typically never pick this.
It is intended only for CI/CD environments where you have no other choice.
Optionally, also set the GitHub API URL
with the spice.forge.github.apiUrl configuration option.
By default, the API URL is assumed to be at /api under the GitHub URL.
v0.13.0Optionally, also set the GitLab API URL
with the spice.forge.gitlab.apiUrl configuration option.
By default, the API URL is the same as the GitLab URL.
To use OAuth authentication with a self-hosted GitLab instance,
you must first set up an OAuth App on the GitLab instance.
Be sure to uncheck the "Confidential" option when creating the App.
This will generate an OAuth Client ID for the App.
By default, git-spice stores your authentication token
in a system-specific secure storage.
On macOS, this is the system Keychain.
On Linux, it uses the Secret Service,
which is typically provided by GNOME Keyring.
Since version v0.3.0,
if your system does not provide a secure storage service,
git-spice will fall back to storing secrets in a plain-text file
at $XDG_CONFIG_HOME/git-spice/secrets.json or the user's configuration directory.
If it does that, it will clearly indicate so at login time,
reporting the full path to the secrets file.
Example
$ gs auth login...WRN Storing secrets in plain text at /home/user/.config/git-spice/secrets.json. Be careful!INF github: successfully logged in
$ gs auth login
...
WRN Storing secrets in plain text at /home/user/.config/git-spice/secrets.json. Be careful!
INF github: successfully logged in