# Sources

> Connect GitHub, GitLab, Gitea, Forgejo, Bitbucket Cloud or Azure DevOps so Corfedo can add and index repositories.

Source: https://docs.corfedo.ai/workspace/sources/

A source is a connection to a code host, such as GitHub or GitLab, that Corfedo adds repositories from. Its credential needs only read access.

## Before you begin

- You are a workspace administrator or have the **Repository administrator** role.
- An account on the forge that can read the repositories you want to index.

## Add a connection

### Choose how to connect

Open **Settings** › **Sources** and select **Add connection**. Choose the code host and the credential:

| Option | Credential | Access it needs |
| --- | --- | --- |
| **GitHub App** | An app installed on an organization or account, with short-lived tokens | Repository permissions Contents and Metadata, read-only |
| **GitHub token** | A fine-grained or classic personal access token | Fine-grained: Contents and Metadata, read-only. Classic: the `repo` scope. |
| **GitLab** | A personal, group or project access token | The `read_api` and `read_repository` scopes, or `api` |
| **Gitea** and **Forgejo** | An access token on your server, with the account name it belongs to | The `read:repository` and `read:user` scopes, and `read:organization` for organization repositories |
| **Bitbucket Cloud** | A workspace access token or an API token with scopes, with the workspace | Repositories, read-only |
| **Azure DevOps** | A personal access token scoped to one organization, with the organization | Code (Read), scoped to the organization |

### Enter the server

GitHub and GitLab connect to `github.com` and `gitlab.com`. For GitHub Enterprise Server or GitLab self-managed, select the option for your own server and enter its **Server URL**. Gitea and Forgejo always need the server URL. Bitbucket Cloud and Azure DevOps connect to their cloud services only.

### Create the credential

The page lists the steps for the forge you chose. Points to watch:

- **GitHub App**: for an app owned by an organization, register it under the organization's Settings › Developer settings › GitHub Apps. The installation ID is the number at the end of the installation page's URL.
- **GitHub token**: an organization may require an owner to approve a fine-grained token.
- **GitLab**: if GitLab asks for a token type, choose Legacy token. A group or project access token needs the Reporter role.
- **Gitea and Forgejo**: enter the **Account name** the token belongs to.
- **Bitbucket Cloud**: workspace access tokens need a Premium plan. Repository and project access tokens work too.
- **Azure DevOps**: the token must be scoped to this organization only.

### Test and save

Enter a **Name** and the credential and select **Test and save**. Corfedo tests the credential on the forge before it saves it.

**Check:** the connection opens and shows **Healthy** next to its name. It has no repositories yet. Next, [add a discovery rule](https://docs.corfedo.ai/workspace/sources/discovery-rules/).

## Disable or delete a connection

**Disable** and **Delete connection** keep its repositories searchable at their last indexed commit, but they stop updating until another connection provides them. Deleting also removes the connection's rules.

## Troubleshooting

| What you see | What to do |
| --- | --- |
| **The connection was not saved** with a reason | The test on the forge failed. Check that the credential has the access listed above and has not expired, then select **Test and save** again. |
| **Needs attention** on a saved connection | The last check failed. Open the connection, select **Test connection** and fix what it reports, for example with **Replace credential**. |
| A warning next to **Expires** | The token expires within 14 days. Create a new token on the forge and select **Replace credential**. |

## Related

- [Discovery rules](https://docs.corfedo.ai/workspace/sources/discovery-rules/) choose which repositories a connection adds.
- [Repositories](https://docs.corfedo.ai/workspace/sources/repositories/) explains statuses, indexing settings and access.
