> For the complete documentation index, see [llms.txt](https://docs.hivel.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hivel.ai/integrations/version-control/github/github-fine-grained-token.md).

# GitHub - Fine-Grained Token

To integrate GitHub with Hivel using a fine-grained token, follow the steps below. This guide ensures a seamless setup, similar to the classic token process but with specific token-based permissions.

**Data Access by Hivel**

* Hivel accesses the past 30-90 days of metadata and pull requests from active repositories during the initial sync.

**Requirements**

* Ensure to log in with an account possessing write permissions to relevant GitHub repositories.

**Best Practice**

1. Opt for a service account rather than an individual-linked account.
2. Service accounts are typically overseen by the company's admin.

### **Steps to generate a Fine-Grained Token on GitHub**

**Quick start:** skip the navigation - [open the token creation page](https://github.com/settings/personal-access-tokens/new), then continue from **step 4**. If the link doesn't take you there, follow from **step 1** below.

#### **Step 1:**&#x20;

**Log in to GitHub** with an account that has write permissions for the repositories you want to integrate.

1\. Navigate to **Profile icon > Settings**

<img src="/files/MqnBqokUmz5lrt3JP96D" alt="" height="434" width="416">

#### **Step 2:**&#x20;

Select **Developer Settings at the end.**

<img src="/files/hKomllPrUNRuwXdpwWgY" alt="" height="290" width="575">

#### **Step 3:**&#x20;

Select **Personal access tokens > Fine-grained tokens.**

<img src="/files/I0sRwOeU4lD6D9QFbALg" alt="" height="288" width="700">

#### **Step 4:**&#x20;

Click **Generate new token**.

1. Give the **token name**, preferably 'Hivel' and set an **Expiration** date as needed.

**Note:** Set the **Resource owner** dropdown to your **organization name**, not your personal account. The **Organization permissions** section (step 4.2.2) only appears when an organization is selected as the resource owner - and a token owned by your personal account cannot access the organization's repositories. If your organization is not listed in the dropdown, an org admin must first allow fine-grained tokens under **Organization Settings > Third-party Access > Personal access tokens** (see steps 4.4-4.9 below).

<img src="/files/C12mDyA1CEdLLWpuZYVi" alt="" height="354" width="598">

\
2\. **Under Repository access**, choose which repositories Hivel should be able to see:

* **Public repositories** - grants read-only access to public repositories.
* **All repositories** - grants access to every current and future repository in the organization.
* **Only select repositories** - restricts the token to the specific repositories (up to 50) you choose to share with Hivel.

![](/files/V0belrIsytQ3T794jgvU)

Pick whichever of these three matches your organization's data-sharing policy with Hivel.

Grant the following permissions:

1. Repository permissions
   1. Contents (read-only)
   2. Metadata (read-only)
   3. Pull Requests (read-only)
2. Organization permissions
   1. Members (read-only)

3\. Click **Generate token** and **copy** the token immediately, as you won't be able to view it again.

4\. Now go back to the homepage and follow the subsequent steps to allow access to fine-grained token: Navigate to **Profile icon > Settings > Organizations**.

<img src="/files/92rM6m52R2LxmEmXjId1" alt="" height="445" width="765">

5. Select the organizations which need to be integrated.

![](/files/m3J5f5BnnRqZvZxiwAbF)

6. Go to Repository settings and scroll to the end of the vertical navigation menu.

   <img src="/files/qF2zZWaAuLB9Yw0w0Ysk" alt="" height="489" width="653">

   \
   7\. At the bottom of the navigation menu, select **Personal Access Token > Settings**.

![](/files/G692BRBh8xxNhRHdLuX1)

8\. Select **Personal access tokens > Fine-grained tokens.**

9\. On this page, select the option to **Allow access via fine-grained personal access tokens.**

![](/files/x6Ms6C4y1QXH04S65JZ3)

#### **Step 6:** **Connect in Hivel**

1. **Copy the generated token** immediately, as you won't be able to view it again.
2. Submit the token to Hivel

Hivel validates the token instantly - if the token is wrong, expired, or missing any of the required permissions, Hivel shows a clear message telling you exactly what the problem is. Generate a new token with the correct permissions and reconnect.

That's it, all done!

<br>
