> 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-cloud/github-cloud-fine-grained-token.md).

# GitHub Cloud - Fine-Grained Token

How to integrate GitHub with 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="https://3057781534-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5KAIOUWph0JLSgQqbzyT%2Fuploads%2Fb0PryrzGSRTAUv4Y0oMV%2Funknown.png?alt=media&amp;token=440fef76-2081-46dc-b7d7-a2ddba9d95be" alt="" height="434" width="416">

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

Select **Developer Settings at the end.**

<img src="https://3057781534-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5KAIOUWph0JLSgQqbzyT%2Fuploads%2F1zsOC5RzWkhhIRTyR7WJ%2Funknown.png?alt=media&amp;token=52c4733e-4f3b-457a-8582-3546ae6a9963" alt="" height="290" width="575">

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

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

<img src="https://3057781534-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5KAIOUWph0JLSgQqbzyT%2Fuploads%2FHREy2EqEtZ5Ls77HIWIA%2Funknown.png?alt=media&amp;token=fa48a957-38a9-4b6a-ad76-a7dc2d646ecc" 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="https://3057781534-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5KAIOUWph0JLSgQqbzyT%2Fuploads%2FccgAbFyYd1ZM8NZrYsrA%2Funknown.png?alt=media&amp;token=f8fce2b7-b79f-4ac1-a8e3-e1a8f76c6aea" 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.

![](https://3057781534-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5KAIOUWph0JLSgQqbzyT%2Fuploads%2FJpw5IC83iOOmsueXvudi%2Funknown.png?alt=media\&token=53d6d964-d6c1-4e42-930e-7a85b7aaef07)

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="https://3057781534-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5KAIOUWph0JLSgQqbzyT%2Fuploads%2FABppi3j4YjhLvBwA1Dck%2Funknown.png?alt=media&amp;token=9ee0d384-003a-422f-9bd2-a436199b20cc" alt="" height="445" width="765">

5. Select the organizations which need to be integrated.

![](https://3057781534-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5KAIOUWph0JLSgQqbzyT%2Fuploads%2FAyreEvNmTene8rSZnXwM%2Funknown.png?alt=media\&token=c803fe8d-81f0-456b-a680-e0d51c27912a)

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

   <img src="https://3057781534-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5KAIOUWph0JLSgQqbzyT%2Fuploads%2FQFDeyMR5yymsoxqYSFd0%2Funknown.png?alt=media&amp;token=9905a10b-abff-43c0-8b6d-db32b20dd966" alt="" height="489" width="653">

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

![](https://3057781534-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5KAIOUWph0JLSgQqbzyT%2Fuploads%2FxvNTjVg17xJ3M7hJoiDB%2Funknown.png?alt=media\&token=3ca260c9-6d6a-464b-9772-a06f771d698e)

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

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

![](https://3057781534-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5KAIOUWph0JLSgQqbzyT%2Fuploads%2FlqyD7rEfhrVB8LhokwNg%2Funknown.png?alt=media\&token=52062ac1-4b78-4e12-83e3-a4247c6edd17)

#### **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>
