# GitHub

Learn how to securely authenticate Mindflow with your GitHub repositories using a fine-grained Personal Access Token (PAT). This guide walks you through generating the required token in GitHub and configuring the API credential within your Mindflow environment.

## Generate a Fine-Grained GitHub PAT

To allow Mindflow to interact with your GitHub data securely, you must first create a repository-scoped access token.

1. **Access Developer Settings** Log in to GitHub, click your profile picture in the top-right corner, and select **Settings**. Scroll down the left sidebar and click **Developer settings**.

   <div class="docs-screenshot-compact">

   ![Access developer settings](./assets/access-developer-settings-2.png)

   </div>

   <div class="docs-screenshot-compact">

   ![Access developer settings](./assets/access-developer-settings.png)

   </div>

1. **Navigate to Fine-Grained Tokens** In the left menu, expand **Personal access tokens** and select **Fine-grained tokens**. Click the **Generate new token** button.

   <div class="docs-screenshot-compact">

   ![Navigate fine grained tokens](./assets/navigate-fine-grained-tokens.png)

   </div>

1. **Configure Token Details**
   - **Token name:** Enter a recognizable name (e.g., `Mindflow Integration`).
   - **Expiration:** Select an appropriate lifespan for your token (e.g., `30 days`).

   <div class="docs-screenshot-compact">

   ![Expiration](./assets/expiration.png)

   </div>

1. **Set Repository Access**

   Under the **Repository access** section, select **Only select repositories** and choose the specific repositories you want Mindflow to access.

   <div class="docs-screenshot-compact">

   ![Set repository access](./assets/set-repository-access.png)

   </div>

1. **Assign Permissions**

   Expand the **Repository permissions** section. Assign the minimal access required for your workflow. For standard read operations, configure the following:
   - **Contents:** `Read-only`
   - **Metadata:** `Read-only`

1. **Generate and Save**

   Scroll to the bottom and click **Generate token**.

   <div class="docs-screenshot-compact">

   ![Generate save](./assets/generate-save.png)

   </div>

:::note
**⚠️ Important:** Copy the generated token immediately and store it in a secure location. GitHub will not display this token again.
:::

## Configure the API Credential in Mindflow

Once your GitHub PAT is generated, you can set up the authentication credential in your Mindflow dashboard.

1. **Navigate to Environments**

   Open Mindflow and go to the **Environments** page.

2. **Create a Credential**

   Locate the target environment or within the Global Environment section and click the + **Create credential** button on the right side.

   <div class="docs-screenshot-compact">

   ![Create credential](./assets/create-credential.png)

   </div>

3. **Select the Integration Service**

   In the **Service** search bar, type `GitHub` and select either the **GitHub** option labeled with the `Native` badge or Vendor.

   <div class="docs-screenshot-compact">

   ![Select integration service](./assets/select-integration-service.png)

   </div>

4. **Configure Credential Details**

   Fill out the form with the following parameters:

   <div class="docs-screenshot-compact">

   ![Configure credential details](./assets/configure-credential-details.png)

   </div>
   - **Credential name:** Enter a clear identifier (e.g., `GitHub credential`).
   - **URL:** Ensure this is set to `https://api.github.com`.
   - **Credential type:** Select **HTTP API Key** from the dropdown menu.

5. **Set the Authorization Header**
   - Click the **Advanced** button to reveal additional settings.
   - Expand the **Headers** menu and click **+ Add item**.
   - In the **Key** field, enter: `Authorization`
   - In the **Value** field, enter: `Bearer`<your_pat_token>``
6. **Save the Credential**

   Click **Update** (or **Create**) to save your configuration. Your GitHub integration is now ready to use in your Mindflow workflows.

:::note
**📝 Formatting Note:** You must include the word `Bearer` followed by a single space before pasting your GitHub token. (Example: `Bearer github_pat_11A...`)
:::
