# Gitea and Forgejo

Source: https://openpanel.sh/docs/git/gitea-forgejo

Connect your own Gitea or Forgejo, or Codeberg, to OpenPanel with an access token, and which permissions it needs.

Gitea and Forgejo accounts read the repositories of the token's user. Use **Gitea** for your own Gitea, and **Forgejo** for your own Forgejo or for [Codeberg](https://codeberg.org).

## The token [#the-token]

An access token with read access to **repository** and **user** (`read:repository`, `read:user`).

1. Sign in to your Gitea or Forgejo, and open **Settings** → **Applications** (the page `/user/settings/applications` on its address). The add dialog links there once you have typed the address.
2. Under **Manage access tokens**, give the token a name, for example `OpenPanel`.
3. Under the permissions, set **repository** to **Read** and **user** to **Read**.
4. Generate the token, and copy it. It is shown only once.

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

1. In **Organization settings** → **Git accounts**, choose **Add Git account** → **Gitea** or **Forgejo**.
2. **Address**: your server's address, for example `https://gitea.example.com`, or `https://codeberg.org`. Type `http://` if your server does not serve HTTPS.
3. For your own server inside the private network, turn on **Reached through the private network**. See [Private Git servers](/docs/network/private-git). Codeberg is on the internet and cannot use it.
4. Paste the token into **Access token**, and choose **Add account**.

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

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

| The console says | What to do |
|---|---|
| Gitea (or Forgejo) did not accept the token. … | Copy the token again, whole, or make a new one. |
| Gitea (or Forgejo) refused the token for this. It needs: Read access to repository and user (read:repository, read:user). | Make a token with both permissions. |
| Nothing answered at …/api/v1/user. Check the address. | Use the server's own address, where its web pages answer. |
| …'s certificate is not trusted (expired, self-signed, or made for another name). | Fix the certificate, or, inside the private network, use `http://`. |
| … answered with a redirect to …. Enter the address it redirects to. | OpenPanel follows no redirects: enter the final address. |