Connections / Connect GitLab
Connect GitLab
Connect mergecat to GitLab with Sign in with GitLab or a personal access token, and set up the OAuth application an administrator registers once.
Connecting GitLab adds merge request titles, authors and links, names of deleted branches, squash and rebase merges, labels, linked issues, CI/CD pipelines, environments and deployments to repositories on gitlab.com. In the app, the Pull requests page is called Merge requests for GitLab repositories.
Sign in
Open File › Connections… (or click Local only · Connect in the toolbar) and use one of the two options on the GitLab card.
Sign in with GitLab (GitLab 17.2 or later). mergecat copies a code to your clipboard and opens GitLab in your browser, where your single sign-on and two-factor authentication apply. Confirm the code and the card shows your account. The app requests the scope api. Access tokens expire after two hours and mergecat refreshes them automatically. This option needs the application ID of a GitLab OAuth application, entered once in Settings › GitLab OAuth application ID (see Administrator setup). Without it the button is disabled and the card says so.
Use a personal access token. Paste a token (glpat-…) and click Connect. Create a token opens GitLab’s token page with the name and the scope preselected.
| Scope | Allows |
|---|---|
api | Everything, including creating merge requests. |
read_api | Reading only: history data, merge requests, pipelines and deployments, but no new merge requests. |
The extension connects GitLab with a personal access token (scope api; read_api is enough to read). Sign in with GitLab in the browser is available when the setting mergecat.gitlab.clientId holds the application ID of an OAuth application, set up as described below.
Tokens are kept in VS Code’s SecretStorage. See VS Code extension.
A GitLab connection belongs to one GitLab instance: the one of the repository that is open when you sign in, else gitlab.com. Tokens are encrypted with the system keychain; see Where credentials are stored. To remove the connection, click Disconnect on the GitLab card.
Administrator setup: OAuth application
Sign in with GitLab needs an OAuth application registered once per GitLab instance. It can belong to a user, a group or the whole instance (admin area). The application ID is not a secret, and no secret is needed.
Open the Applications settings
Choose where the application lives: your user settings, a group’s settings or the admin area of the instance, then open Applications and add a new application.
Configure it
Name it, for example “mergecat”. Clear Confidential: the application must be non-confidential, because the desktop app cannot keep a secret. Select the scope api and enable the device authorization grant.
Share the application ID
Save the application and copy its Application ID. Each person enters it in the desktop Settings › GitLab OAuth application ID (or you provide it through MERGECAT_GITLAB_CLIENT_ID); VS Code users put it in the setting mergecat.gitlab.clientId.
Environment variables
| Variable | Purpose |
|---|---|
MERGECAT_GITLAB_CLIENT_ID | OAuth application ID for Sign in with GitLab. Fills the setting when it is empty. |
MERGECAT_GITLAB_URL | GitLab instance URL, for self-managed GitLab and tests. |
All variables are listed in Configuration.
Self-managed GitLab
Remotes of self-managed GitLab instances are not recognised yet: only gitlab.com remotes are. Repositories on another GitLab host show as local repositories.
Troubleshooting
| Symptom | What to do |
|---|---|
| Sign in with GitLab is disabled | Enter the OAuth application ID in Settings, or use a personal access token. |
| The sign-in page reports an error | Check that the instance runs GitLab 17.2 or later and that the application is non-confidential, has the scope api and allows the device authorization grant. |
GitLab rejected the token (expired, revoked or for another instance). | Create a new token, or sign in again. |
Project … was not found on …, or the account has no access to it. | Check the remote URL, your membership of the project and the token scope. |
GitLab denied the … It needs a token with the "api" scope and at least the Developer role in the project. | Creating merge requests needs the api scope and the Developer role or higher. |
The GitLab sign-in expired (…). Sign in again in Connections. | The refresh failed, for example after the application was changed: sign in again. |
API rate limit reached; it resets at … | Wait until the time shown, then refresh. |