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, GitLab, and Bitbucket Cloud.
Note that GitLab support requires at least version v0.9.0.
Bitbucket Cloud support requires at least version Unreleased.
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.
Git Credential Manager
(GCM) is a secure credential storage system for Git.
If you already have GCM configured for GitHub or Bitbucket,
git-spice can reuse those credentials automatically.
$ gs auth loginSelect an authentication method: Git Credential ManagerINF successfully logged in
$ gs auth login
Select an authentication method: Git Credential Manager
INF successfully logged in
Push or pull from a GitHub or Bitbucket repository once.
This triggers the OAuth flow in your browser.
After that, git-spice will use the stored OAuth token automatically.
Additionally, if you have GCM configured,
git-spice will automatically fall back to GCM credentials
when no other authentication token is available—even
without running gs auth login.
account - read workspace members for reviewer lookup
Click "Create" and copy the generated token.
$ gs auth loginSelect an authentication method: API TokenEnter Atlassian account email: user@example.comEnter API token:INF bitbucket: successfully logged in
$ gs auth login
Select an authentication method: API Token
Enter Atlassian account email: user@example.com
Enter API token:
INF bitbucket: successfully logged in
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.
Set the BITBUCKET_TOKEN environment variable to your OAuth token.
This should be a Bearer token (OAuth access 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.
GitHub App is similar,
but it may be preferable if you don't want to give git-spice
access to all your repositories.
Git Credential Manager
is convenient if you already have GCM installed for git operations.
git-spice can reuse your existing GCM credentials automatically,
and will fall back to them even without explicit login.
Service CLI is the most convenient method
if you already have the GitHub CLI installed and authenticated.
It loses security benefits of the other methods,
as it re-uses the token assigned to the CLI.
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.
OAuth is best if you have the permissions needed
to install it on all repositories that you want to use git-spice with.
Service CLI is the most convenient method if you already have
the GitLab CLI installed and authenticated.
It loses security benefits of the other methods,
as it re-uses the token assigned to the CLI.
Personal Access Token is flexible and secure.
It may be used even with repositories where you don't have permission to
install OAuth Apps.
However, it requires manual token management, making it less convenient.
Git Credential Manager integrates with
Bitbucket's OAuth flow and handles token refresh automatically.
This is convenient if you already have GCM installed for git operations.
API Token is flexible and secure.
It requires manual token management but works without additional tools.
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