# GitLab

Source: https://openpanel.sh/docs/git/gitlab

Connect a gitlab.com or self-managed GitLab account to OpenPanel with a personal access token, and which scopes it needs.

A GitLab account reads every project its token's user is a member of. It works with gitlab.com and with your own GitLab, including one inside your private network.

## The token [#the-token]

A personal access token with the scopes `read_api` and `read_repository`.

1. Open the token page. On gitlab.com it is [gitlab.com/-/user_settings/personal_access_tokens?name=OpenPanel&scopes=read_api,read_repository](https://gitlab.com/-/user_settings/personal_access_tokens?name=OpenPanel&scopes=read_api,read_repository); on your own GitLab, the same path on its address. The add dialog links to it, with the name and both scopes filled in.
2. Choose an expiration date.
3. Check that **read_api** and **read_repository** are ticked, and create the token.
4. Copy the token. GitLab shows it only once.

## Add the account [#add-the-account]

1. In **Organization settings** → **Git accounts**, choose **Add Git account** → **GitLab**.
2. **Address**: leave `https://gitlab.com`, or enter your own GitLab's address. A GitLab served below a path, such as `https://example.com/gitlab`, works too.
3. For your own GitLab inside the private network, turn on **Reached through the private network**. See [Private Git servers](/docs/network/private-git).
4. Paste the token into **Personal access token**, and choose **Add account**.

OpenPanel checks the token at once and shows whose it is and how many projects it reads. If the check fails, nothing is saved.

## If the check fails [#if-the-check-fails]

| The console says | What to do |
|---|---|
| GitLab did not accept the token. Check that it was copied whole and has not expired or been revoked. | Copy the token again, whole, or make a new one. |
| GitLab refused the token for this. It needs: The read_api and read_repository scopes. | Make a token with both scopes. |
| Nothing answered at …/api/v4/user. Check the address. | Check your GitLab's address. |
| … has a private address. … turn on "Reached through the private network". | Your GitLab is inside your network: turn the switch on. |
| gitlab.com is on the internet. Turn off "Reached through the private network". | gitlab.com is reached directly: turn the switch off. |

GitLab tokens expire. When one does, the account shows **Failed** at its next check: remove the account and add it again with a new token.