> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mayil.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# GitLab

## Installing Mayil's GitLab integration

Follow these steps to link GitLab to a deployed Mayil instance

### 1. Install Mayil-bot on GitLab

Mayil is installed at the Group level. To learn more, see [docs.gitlab.com/integration](https://docs.gitlab.com/ee/integration/oauth_provider.html#create-a-group-owned-application).

1. Go to the desired group.
2. On the left sidebar, select `Settings` > `Applications`.
3. Select `Add new application`
4. Enter `Mayil-bot` under Name.
5. Under URI, enter `<mayil-deployment>/gitlab/auth` where `<mayil-deployment>` is the url in which your mayil deployment can be found (such as `mayil.examplecompany.com` or `companyname.mayil.ai`)
6. Select only the `read_repository` OAuth 2 scope.
7. Select Save application. GitLab provides:
   * The OAuth 2 Client ID in the Application ID field.

   * The OAuth 2 Client Secret, accessible by selecting Copy in the Secret field.

   * The Renew secret function

   * The redirect uri you provided
     Save these details for the next step.

### 2. Authenticate Mayil's backend using OAuth 2.0

We will need to manually authenticate Mayil's backend to work with our newly installed application. For more details, see [docs.gitlab.com/authorization](https://docs.gitlab.com/ee/api/oauth2.html#authorization-code-flow)

1. Construct this link using the details we got from the previous step-

   `https://<GITLAB INSTANCE>/oauth/authorize?client_id=<APP_ID>&redirect_uri=<REDIRECT_URI>&response_type=code&state=STATE&scope=read_repository`

2. Open the above constructed link in a browser and follow the authentication steps.

3. You should be redirected to Mayil's deployment and see a `{"status": "gitlab authenticated"}` message.

This completes setting up Mayil's GitLab integration

## Deleting Mayil's GitLab integration

1. On the left sidebar, select `Settings` > `Applications`
2. Open `Mayil-bot` and select `Destroy`
