> ## 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 connector if your organization is on `github.com`. You can manage one organization per GitHub App, or several organizations with a single personal access token. It's the only GitHub connector that supports fine-grained personal access tokens. To compare the GitHub connectors and pick the right one, see [Choose a GitHub connector](https://www.c1.ai/docs/baton/choose-github-connector.md).

## Capabilities

| Resource | Sync | Provision |
| :- | :- | :- |
| Accounts | | |
| Repositories | | |
| Teams | | |
| Orgs | | |
| Org roles | | |
| GitHub Apps (NHI) | | |
| Secrets - API keys | | |

The GitHub connector supports [automatic account provisioning and deprovisioning](https://www.c1.ai/docs/product/admin/account-provisioning.md). New accounts will send an invitation to the account owner; while an invitation is pending, the account status will be shown as **Pending**. Expired invitations also report **Pending**, distinguished by `invitation_expired` in the status details.

> [!NOTE]
>
> **Enterprise Managed Users (EMU):** If your GitHub organization uses Enterprise Managed Users, account provisioning fails with an error stating that accounts are provisioned by your identity provider, because GitHub does not allow org invitations for managed users. To create accounts for EMU users, use your identity provider's GitHub SCIM integration. The connector still syncs and governs access for existing EMU users.

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](https://www.c1.ai/docs/product/admin/inventory.md) and display them on the **Inventory** page.

[This connector syncs non-human identities](https://www.c1.ai/docs/product/admin/nhi.md) and displays them on the **Identities overview** dashboard.

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

> [!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.

**Step 1**

In GitHub, click your profile photo, then click **Settings**.

**Step 2**

In the left sidebar, select **Developer settings**.

**Step 3**

Click **Personal access tokens > Tokens (classic)**.

**Step 4**

Click **Generate new token > Generate new token (classic)**.

**Step 5**

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

**Step 6**

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

**Step 7**

Click **Generate token**. Carefully copy and save the new token.

> [!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).

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

> [!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).

**Step 1**

In GitHub, click your profile photo, then click **Settings**.

**Step 2**

In the left sidebar, select **Developer settings**.

**Step 3**

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

**Step 4**

Click **Generate new token**.

**Step 5**

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

**Step 6**

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

In the **Repository access** section of the page, select **All repositories**.

**Step 8**

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

* Organization permissions:

  * **Administration**: Read-only access (required to sync installed GitHub Apps)
  * **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.**

**Step 9**

Click **Generate token**. Carefully copy and save the new token.

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

**Step 1**

In GitHub, navigate to **Your organizations** > **Settings**.

**Step 2**

In the left sidebar, select **Developer settings**.

**Step 3**

Click **GitHub Apps**.

**Step 4**

Click **New GitHub App**.

**Step 5**

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

**Step 6**

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

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

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

**Step 9**

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

**Step 10**

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

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

Click **Create GitHub App**. The app is created.

**Step 13**

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

**Step 14**

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

**Step 15**

Carefully save the private key file.

The connector accepts a PEM-encoded **RSA** private key in either format, so no conversion is needed:

* **PKCS#1** — header line `-----BEGIN RSA PRIVATE KEY-----`, which is what **Generate a private key** produces
* **PKCS#8** — header line `-----BEGIN PRIVATE KEY-----`, which is what OpenSSL 3.0+ produces by default

When you configure the connector, you can supply either the key file itself or the PEM contents of that file.

**Step 16**

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

**Step 17**

Find your app and click **Edit** > **Install App**.

**Step 18**

Click **Install** next to the GitHub organization where you want to install the app.

**Step 19**

Select the repositories the app can act on.

**Step 20**

Click **Install**.

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

> [tab] Cloud-hosted
>
> **Follow these instructions to use a built-in, no-code connector hosted by C1.**
>
> **Step 1**
>
> In C1, navigate to **Apps** > **Connectors** and click **Add connector**.
>
> **Step 2**
>
> Search for **GitHub v2** and click **Add**.
>
> **Step 3**
>
> Choose where to add the connector: **Create a new app**, or **Add to an existing app** (then select the app).
>
> If you're creating a new app, choose whether to link it to an application discovered from your identity provider: select **Yes** and pick the IdP application, or **No** to continue with just the connector.
>
> **Step 4**
>
> Set the connector's **Name** and, optionally, a **Description**.
>
> **Step 5**
>
> Click the pencil icon next to **Owners** to choose who can configure and manage this connector.
>
> **Step 6**
>
> Click **Add**. The connector is created and its configuration page opens.
>
> **Step 7**
>
> Find the **Settings** area of the page and click **Edit**.
>
> **Step 8**
>
> 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**.
>
> 5. **Optional.** If your GitHub organization has thousands of repositories or members, click to enable **Optimize sync for large organizations**. See [Optimize sync for large organizations](#optimize-sync-for-large-organizations) for what changes when this option is enabled.
>
> **Step 9**
>
> 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. Provide the GitHub App's private key one of two ways:
>    * Click **Choose file** and upload your private key (`.pem`) file, or
>    * Paste the key's raw PEM contents into the **GitHub App private key (PEM)** field. Because this field only accepts a single line of text, replace every line break in the PEM with a literal `\n` (backslash, then the letter `n`) before pasting it in — the connector unescapes these back into real line breaks. If both fields are filled in, the pasted **GitHub App private key (PEM)** value takes precedence.
>
>      Pasting the file's contents unchanged does not work: the browser replaces the line breaks with spaces, and the connector rejects the value with `invalid private key PEM format`. Run this to produce the single-line form, then paste the result:
>
>      ```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
>      awk '{printf "%s\\n", $0}' your-private-key.pem
>      ```
>
> 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](https://www.c1.ai/docs/product/admin/inventory.md) 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**.
>
> 7. **Optional.** If your GitHub organization has thousands of repositories or members, click to enable **Optimize sync for large organizations**. See [Optimize sync for large organizations](#optimize-sync-for-large-organizations) for what changes when this option is enabled.
>
> **Step 10**
>
> Click **Save**.
>
> **Step 11**
>
> The connector's label changes to **Syncing**, followed by **Connected**. You can view the logs to ensure that information is syncing.
>
> **Done.** Your GitHub connector is now pulling access data into C1.

> [tab] 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
>
> **Step 1**
>
> In C1, navigate to **Apps** > **Connectors** > **Add connector**.
>
> **Step 2**
>
> Search for **Baton** and click **Add**.
>
> **Step 3**
>
> Choose where to add the connector: **Create a new app**, or **Add to an existing app** (then select the app).
>
> If you're creating a new app, choose whether to link it to an application discovered from your identity provider: select **Yes** and pick the IdP application, or **No** to continue with just the connector.
>
> **Step 4**
>
> Set the connector's **Name** and, optionally, a **Description**.
>
> **Step 5**
>
> Click the pencil icon next to **Owners** to choose who can configure and manage this connector.
>
> **Step 6**
>
> Click **Add**. The connector is created and its configuration page opens.
>
> **Step 7**
>
> In the **Settings** area of the page, click **Edit**.
>
> **Step 8**
>
> Click **Rotate** to generate a new Client ID and Secret.
>
> Carefully copy and save these credentials. We'll use them in Step 2.
>
> ### 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>
>   # Supply the private key one of two ways:
>   BATON_APP_PRIVATEKEY_PATH: /etc/baton-github/keys/private-key.pem
>   # ...or pass the raw PEM contents directly (takes precedence when both are set):
>   # BATON_APP_PRIVATEKEY: <Raw PEM contents of the private key 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
>
>   # Optional: enable for orgs with thousands of repos or members to reduce sync time.
>   # See "Optimize sync for large organizations" below for trade-offs.
>   BATON_DIRECT_COLLABORATORS_ONLY: true
>
> ---
> # baton-github-app-key-secret.yaml
> apiVersion: v1
> kind: Secret
> metadata:
>   name: baton-github-app-key
> type: Opaque
> stringData:
>   private-key.pem: |
>     <Contents of the GitHub app's private key (.pem) file>
> ```
>
> If you're using `BATON_APP_PRIVATEKEY_PATH`, the private key must be mounted into the container as a file rather than passed as an environment variable. The manifest above stores the key in its own Secret so it can be mounted as a volume in the deployment configuration below. Set `BATON_APP_PRIVATEKEY_PATH` to the path where the key will be mounted. If you use `BATON_APP_PRIVATEKEY` instead, the raw PEM contents are passed directly and no volume mount is needed.
>
> 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: public.ecr.aws/conductorone/baton-github:latest
>         imagePullPolicy: IfNotPresent
>         env:
>         - name: BATON_HOST_ID
>           value: baton-github
>         envFrom:
>         - secretRef:
>             name: baton-github-secrets
>         volumeMounts:
>         - name: github-app-key
>           mountPath: /etc/baton-github/keys
>           readOnly: true
>       volumes:
>       - name: github-app-key
>         secret:
>           secretName: baton-github-app-key
> ```
>
> The `volumeMounts` and `volumes` entries above are only needed if you're configuring the connector with a GitHub app using `BATON_APP_PRIVATEKEY_PATH`. Omit them if you're using an access token or `BATON_APP_PRIVATEKEY` instead.
>
> ### Step 3: Deploy the connector
>
> **Step 1**
>
> Create a namespace in which to run C1 connectors (if desired), then apply the secret config and deployment config files.
>
> **Step 2**
>
> 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.
>
> **Done.** Your GitHub connector is now pulling access data into C1.

## Optimize sync for large organizations

By default, the connector fetches the full collaborator list for every repository, including users whose access comes from team membership. For organizations with thousands of repositories and members, this can make syncs slow and run up against GitHub API rate limits.

Enabling **Optimize sync for large organizations** (env var: `BATON_DIRECT_COLLABORATORS_ONLY`) changes how the connector discovers repository access:

* **Direct collaborators only.** GitHub is asked only for users with direct repository access. Team-based access is reconstructed from team membership, which the connector already syncs separately.
* **Skips per-team detail calls.** The `members_count` and `repos_count` profile fields are not synced for team resources.

**Enable this option if** your GitHub organization has thousands of repositories or thousands of members and you want faster syncs and fewer API calls. Repository access data in C1 is equivalent — only the way grants are sourced (direct vs. team-expanded) differs.

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