# How to create Github fine-grained token for Hivel Integration?

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

**Data Access by Hivel**

* Hivel accesses the past 60-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.
* Write permissions are mandatory for webhook publication, facilitating real-time data sync.

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

1. **Log in to GitHub** with an account that has write permissions for the repositories you want to integrate.
2. Navigate to **Profile icon** **>** **Settings > Developer Settings**.
3. Select **Personal access tokens** > **Fine-grained tokens**.
4. Click **Generate new token**.
5. Give the **token name**, preferably 'Hivel' and set an **Expiration** date as needed.
6. Grant the following permissions:
   1. Repository permissions
      1. Contents (read-only)
      2. Metadata (read-only)
      3. Pull Requests (read-only)
      4. Webhooks (read and write)
   2. Organization permissions
      1. Members (read-only)
7. Click **Generate token** and **copy** the token immediately. Store it securely and share it with us.
8. Now go back to the homepage and follow the subsequent steps to allow access to fine-grained token: Navigate to **Profile icon** **>** **Settings > Organizations**.
9. Select the organizations which need to be integrated.
10. Go to Repository settings and scroll to the end of the navigation menu.
11. At the bottom of the navigation menu, select **Personal Access Token > Settings**.
12. Select **Personal access tokens** **>** **Fine-grained tokens**.
13. On this page, select the option to **Allow access via fine-grained personal access tokens**.

That's it, all done!

### Screenshots for reference:

<figure><img src="/files/cOrHfTqKv5rlDiPjgqqt" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/ZR9N4bUMh3udLh4nT4Hx" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/7dQYvN6n2jVsSWFjBy5C" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/trUKDpbMy9zdrYaHQply" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/QwVq5pcuNlLgH2ziWNrk" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hivel.ai/integrations/scm/github/alternate-methods/how-to-create-github-fine-grained-token-for-hivel-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
