> ## Documentation Index
> Fetch the complete documentation index at: https://www.c1.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up a GitHub connector

> C1 provides identity governance and just-in-time provisioning for GitHub. Integrate your GitHub instance with C1 to run user access reviews (UARs), enable just-in-time access requests, and automatically provision and deprovision access.

<Tip>
  **This is an updated and improved version of the GitHub integration!** The v2 version of the GitHub integration adds provisioning support for repositories and modernizes the underlying architecture. If you're setting up a GitHub connector with C1 for the first time, you're in the right place.

  Use this integration if your organization accesses GitHub at `github.com`. If you use a custom domain, follow the instructions to set up the [GitHub Enterprise](/baton/github-enterprise) integration.
</Tip>

## Capabilities

| Resource           | Sync                                                          | Provision                                                     |
| :----------------- | :------------------------------------------------------------ | :------------------------------------------------------------ |
| Accounts           | <Icon icon="square-check" iconType="solid" color="#c937ae" /> | <Icon icon="square-check" iconType="solid" color="#c937ae" /> |
| Repositories       | <Icon icon="square-check" iconType="solid" color="#c937ae" /> | <Icon icon="square-check" iconType="solid" color="#c937ae" /> |
| Teams              | <Icon icon="square-check" iconType="solid" color="#c937ae" /> | <Icon icon="square-check" iconType="solid" color="#c937ae" /> |
| Orgs               | <Icon icon="square-check" iconType="solid" color="#c937ae" /> | <Icon icon="square-check" iconType="solid" color="#c937ae" /> |
| Secrets - API keys | <Icon icon="square-check" iconType="solid" color="#c937ae" /> |                                                               |

The GitHub connector supports [automatic account provisioning and deprovisioning](/product/admin/account-provisioning). New accounts will send an invitation to the account owner; if an invitation is pending, the account status will be shown as **Unspecified**.

Repository permissions that are inherited through team membership are labeled as such on the relevant entitlement's **Grants** tab in the C1 web app.

[This connector can sync secrets](/product/admin/inventory) and display them on the **Inventory** page.

## Gather GitHub credentials

Configuring the connector requires you to pass in credentials generated in GitHub. Gather these credentials before you move on. To set up the GitHub connector, you can choose to create a personal access token (classic), a fine-grained access token, or a GitHub app.

You must set up the connector with a GitHub app to have the option of syncing secrets.

### Option 1: Use a personal access token (classic)

Follow these instructions to integrate your GitHub instance by using a [GitHub personal access token (classic)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#types-of-personal-access-tokens).

<Warning>
  A user with the **Org Owner** access in GitHub must perform this task.
</Warning>

<Tip>
  If you're using SAML single sign-on, avoid a `You must grant your Personal Access token access to this organization` error by following the [Authorizing a personal access token for use with SAML single sign-on](https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating-with-saml-single-sign-on/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on) instructions in the GitHub documentation.
</Tip>

<Steps>
  <Step>
    In GitHub, click your profile photo, then click **Settings**.
  </Step>

  <Step>
    In the left sidebar, select **Developer settings**.
  </Step>

  <Step>
    Click **Personal access tokens > Tokens (classic)**.
  </Step>

  <Step>
    Click **Generate new token > Generate new token (classic)**.
  </Step>

  <Step>
    Name your token (for example, **C1 Integration**). Optionally, add a token expiration date.
  </Step>

  <Step>
    Select the following **Scopes:**

    * **repo** - select all
    * **admin:org** - select all if using C1 for GitHub provisioning (see the note below), or **read::org** otherwise
    * **user** - select all

    <Warning>
      The **write::org** scope is used by C1 when automatically provisioning and deprovisioning GitHub access on your behalf. **If you do not want C1 to perform these tasks for you, do not give your token this scope.**
    </Warning>
  </Step>

  <Step>
    Click **Generate token**. Carefully copy and save the new token.
  </Step>
</Steps>

<Warning>
  If you use SAML SSO, you must authorize the PAT using [these instructions](https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating-with-saml-single-sign-on/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on).
</Warning>

**Done.** Next, move on to the connector configuration instructions.

### Option 2: Use a fine-grained access token

Follow these instructions to integrate your GitHub instance by using a [GitHub fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#types-of-personal-access-tokens).

<Warning>
  A user with **Org Owner** access in GitHub must perform this task.
</Warning>

<Tip>
  **Before you begin:** Make sure that your GitHub organization is set up to allow use of fine-grained personal access tokens by following the GitHub documentation on [Setting a personal access token policy for your organization](https://docs.github.com/en/enterprise-cloud@latest/organizations/managing-programmatic-access-to-your-organization/setting-a-personal-access-token-policy-for-your-organization).
</Tip>

<Steps>
  <Step>
    In GitHub, click your profile photo, then click **Settings**.
  </Step>

  <Step>
    In the left sidebar, select **Developer settings**.
  </Step>

  <Step>
    Click **Personal access tokens > Fine-grained tokens**.
  </Step>

  <Step>
    Click **Generate new token**.
  </Step>

  <Step>
    Name your token (for example, **C1 Integration**) and set a token expiration date. Optionally, add a description.
  </Step>

  <Step>
    In the **Resource owner** dropdown, select a resource owner. The token is able to access resources owned by the selected resource owner. Organizations will not appear unless they have opted in to fine-grained personal access tokens.
  </Step>

  <Step>
    In the **Repository access** section of the page, select **All repositories**.
  </Step>

  <Step>
    In the **Permissions** section of the page, give the token the following permissions:

    * Organization permissions:

      * **Members**: Read and write access
      * **Custom organization roles**: Read and write access

    * Repository permissions:

      * **Administration**: Read and write access
      * **Metadata**: Read-only access

    <Warning>
      The repository permissions are used by C1 to sync and display data on repo membership, and to provision repository permissions for GitHub accounts. **If you do not want C1 to sync and display your GitHub organization's repo data, do not give your token these permissions.**
    </Warning>
  </Step>

  <Step>
    Click **Generate token**. Carefully copy and save the new token.
  </Step>
</Steps>

**Done.** Next, move on to the connector configuration instructions.

### Option 3: Use a GitHub app

Follow these instructions to integrate your GitHub instance by using a [GitHub app](https://docs.github.com/en/apps/creating-github-apps/about-creating-github-apps/about-creating-github-apps).

This process creates a GitHub app that is only available to your GitHub organization, then generates an installation token for that app, which can be used to integrate the GitHub organization with C1. This creates the equivalent of a personal access token, but does not tie the token to a specific identity.

**If you want to integrate multiple GitHub organizations with C1, you must create an app and set up a connector for each one.**

<Warning>
  A user with the **Org Owner** permission in the GitHub organization to be integrated with C1 must perform this task.
</Warning>

<Steps>
  <Step>
    In GitHub, navigate to **Your organizations** > **Settings**.
  </Step>

  <Step>
    In the left sidebar, select **Developer settings**.
  </Step>

  <Step>
    Click **GitHub Apps**.
  </Step>

  <Step>
    Click **New GitHub App**.
  </Step>

  <Step>
    Give the app a globally unique name, such as "c1-integration-`<org name>`". There is a 34 character limit.
  </Step>

  <Step>
    In the **Homepage URL** field, enter a placeholder URL such as `http://example.com`. Because this app is not public, it does not have or need a website to direct other users to, so we can use a placeholder URL.
  </Step>

  <Step>
    In the **Callback URL** field, enter a placeholder URL such as `http://example.com`. This app will not use a callback, so we can use a placeholder URL.
  </Step>

  <Step>
    Check the **Expire user authorization tokens** and **Enable Device Flow** checkboxes to enable these settings.
  </Step>

  <Step>
    In the **Webhook** section of the page, uncheck the **Active** checkbox to disable this setting.
  </Step>

  <Step>
    In the **Permissions** section of the page, give the app the following permissions:

    * Repository permissions:

      * **Administration**: Read and write access
      * **Metadata**: Read-only access

    * Organization permissions:

      * **Administration**: Read-only access (required to detect SAML/SSO configuration)
      * **Custom organization roles**: Read and write access
      * **Members**: Read and write access

    For details, see the GitHub docs on [Permissions required for GitHub Apps](https://docs.github.com/en/enterprise-cloud@latest/rest/authentication/permissions-required-for-github-apps).
  </Step>

  <Step>
    In the **Where can this app be installed?** section of the page, choose **Only on this account**. This limits the app's scope to the GitHub Enterprise organization you've set it up on.
  </Step>

  <Step>
    Click **Create GitHub App**. The app is created.
  </Step>

  <Step>
    On the app's details page, carefully copy and save the **App ID**.
  </Step>

  <Step>
    Scroll down to the **Private keys** section of the app's page and click **Generate a private key**.
  </Step>

  <Step>
    Carefully save the private key file.
  </Step>

  <Step>
    Finally, install the new app on your GitHub organization. Navigate to **Developer Settings** > **GitHub Apps**.
  </Step>

  <Step>
    Find your app and click **Edit** > **Install App**.
  </Step>

  <Step>
    Click **Install** next to the GitHub organization where you want to install the app.
  </Step>

  <Step>
    Select the repositories the app can act on.
  </Step>

  <Step>
    Click **Install**.
  </Step>
</Steps>

**Done.** Next, move on to the connector configuration instructions.

## Configure the GitHub connector

<Warning>
  To complete this task, you'll need:

  * The **Connector Administrator** or **Super Administrator** role in C1
  * Access to the set of GitHub credentials generated by following the instructions above
</Warning>

<Tabs>
  <Tab title="Cloud-hosted">
    **Follow these instructions to use a built-in, no-code connector hosted by C1.**

    <Steps>
      <Step>
        In C1, navigate to **Integrations** > **Connectors** and click **Add connector**.
      </Step>

      <Step>
        Search for **GitHub v2** and click **Add**.
      </Step>

      <Step>
        Choose how to set up the new GitHub connector:

        * Add the connector to a currently unmanaged app (select from the list of apps that were discovered in your identity, SSO, or federation provider that aren't yet managed with C1)

        * Add the connector to a managed app (select from the list of existing managed apps)

        * Create a new managed app
      </Step>

      <Step>
        Set the owner for this connector. You can manage the connector yourself, or choose someone else from the list of C1 users. Setting multiple owners is allowed.

        If you choose someone else, C1 will notify the new connector owner by email that their help is needed to complete the setup process.
      </Step>

      <Step>
        Click **Next**.
      </Step>

      <Step>
        Find the **Settings** area of the page and click **Edit**.
      </Step>

      <Step>
        If you're using a personal access token to set up the connector:

        1. Click **Personal access token**.

        2. Paste the token you generated into the **Personal access token** field.

        3. **Optional.** If you want to sync only specific GitHub organizations, enter the organizations' names in the **Orgs** field. If you do not specify specific organizations, C1 will sync all organizations.

        4. **Optional.** If you do not want to include archived repos in syncs, click to enable **Omit archived repositories**.
      </Step>

      <Step>
        If you're using a GitHub app to set up the connector:

        1. Click **GitHub app**.

        2. Enter your app ID into the **GitHub app ID** field.

        3. Click **Choose file** and upload your private key file.

        4. In the **Organization** field, enter the name of the GitHub organization associated with the GitHub app. **You must enter a single organization name in this field or the connector configuration will fail.**

        5. **Optional.** Click to enable **Sync secrets**. [Synced secrets](/product/admin/inventory) are displayed on the **Inventory** page.

        6. **Optional.** If you do not want to include archived repos in syncs, click to enable **Omit archived repositories**.
      </Step>

      <Step>
        Click **Save**.
      </Step>

      <Step>
        The connector's label changes to **Syncing**, followed by **Connected**. You can view the logs to ensure that information is syncing.
      </Step>
    </Steps>

    **Done.** Your GitHub connector is now pulling access data into C1.
  </Tab>

  <Tab title="Self-hosted">
    **Follow these instructions to use the GitHub connector, hosted and run in your own environment.**

    When running in service mode on Kubernetes, a self-hosted connector maintains an ongoing connection with C1, automatically syncing and uploading data at regular intervals. This data is immediately available in the C1 UI for access reviews and access requests.

    ### Resources

    * [Official download center](https://dist.conductorone.com/ConductorOne/baton-github): For stable binaries (Windows/Linux/macOS) and container images.

    * [GitHub repository](https://github.com/conductorone/baton-github): Access the source code, report issues, or contribute to the project.

    ### Step 1: Set up a new GitHub connector

    <Steps>
      <Step>
        In C1, navigate to **Integrations** > **Connectors** > **Add connector**.
      </Step>

      <Step>
        Search for **Baton** and click **Add**.
      </Step>

      <Step>
        Choose how to set up the new GitHub connector:

        * Add the connector to a currently unmanaged app (select from the list of apps that were discovered in your identity, SSO, or federation provider that aren't yet managed with C1)

        * Add the connector to a managed app (select from the list of existing managed apps)

        * Create a new managed app
      </Step>

      <Step>
        Set the owner for this connector. You can manage the connector yourself, or choose someone else from the list of C1 users. Setting multiple owners is allowed.

        If you choose someone else, C1 will notify the new connector owner by email that their help is needed to complete the setup process.
      </Step>

      <Step>
        Click **Next**.
      </Step>

      <Step>
        In the **Settings** area of the page, click **Edit**.
      </Step>

      <Step>
        Click **Rotate** to generate a new Client ID and Secret.

        Carefully copy and save these credentials. We'll use them in Step 2.
      </Step>
    </Steps>

    ### Step 2: Create Kubernetes configuration files

    Create two Kubernetes manifest files for your GitHub connector deployment:

    #### Secrets configuration

    ```yaml expandable theme={"theme":{"light":"css-variables","dark":"css-variables"}}
    # baton-github-secrets.yaml
    apiVersion: v1
    kind: Secret
    metadata:
      name: baton-github-secrets
    type: Opaque
    stringData:
      # C1 credentials
      BATON_CLIENT_ID: <C1 client ID>
      BATON_CLIENT_SECRET: <C1 client secret>
      
      # GitHub credentials if configuring with an access token
      BATON_TOKEN: <GitHub access token>
      BATON_ORGS: <Optional - list of GitHub orgs that you want to sync>

      # GitHub credentials if configuring with a GitHub app
      BATON_APP_ID: <GitHub app ID>
      BATON_APP_PRIVATEKEY_PATH: <Path to the private key file for the GitHub app>
      BATON_ORGS: <Name of the single GitHib org the app was created for>

      # Optional: include if you want C1 to provision access using this connector
      BATON_PROVISIONING: true

      # Optional: include if you do not want to sync archived repos
      BATON_OMIT_ARCHIVED_REPOSITORIES: true
    ```

    See the connector's README or run `--help` to see all available configuration flags and environment variables.

    #### Deployment configuration

    ```yaml expandable theme={"theme":{"light":"css-variables","dark":"css-variables"}}
    # baton-github.yaml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: baton-github
      labels:
        app: baton-github
    spec:
      selector:
        matchLabels:
          app: baton-github
      template:
        metadata:
          labels:
            app: baton-github
            baton: true
            baton-app: github
        spec:
          containers:
          - name: baton-github
            image: ghcr.io/conductorone/baton-github:latest
            imagePullPolicy: IfNotPresent
            env:
            - name: BATON_HOST_ID
              value: baton-github
            envFrom:
            - secretRef:
                name: baton-github-secrets
    ```

    ### Step 3: Deploy the connector

    <Steps>
      <Step>
        Create a namespace in which to run C1 connectors (if desired), then apply the secret config and deployment config files.
      </Step>

      <Step>
        Check that the connector data uploaded correctly. In C1, click **Apps**. On the **Managed apps** tab, locate and click the name of the application you added the GitHub connector to. GitHub data should be found on the **Entitlements** and **Accounts** tabs.
      </Step>
    </Steps>

    **Done.** Your GitHub connector is now pulling access data into C1.
  </Tab>
</Tabs>

## Troubleshooting

### "Resource not accessible by integration" error

If you see this error during sync, it most commonly means the GitHub App is missing the **Organization administration: Read-only** permission.

This permission is required because the connector queries GitHub's GraphQL API to check whether your organization has SAML/SSO configured. GitHub restricts this data to apps with organization admin read access. Without it, the sync will fail.

**To fix:** Go to your GitHub App settings, then navigate to **Permissions** > **Organization permissions** > **Administration** and set it to **Read-only**.
