> Documentation index: https://metorial.com/llms.txt. Every page is available as Markdown by adding .md to its URL.

# Connect GitHub to your AI agents with per-user sign-in
URL: https://metorial.com/docs/platform/integrations/github

Publish GitHub in a Metorial portal so each employee signs in with their own GitHub account, with your own OAuth app, narrowed scopes and read-only tools.

---

To connect GitHub, an admin shares the GitHub integration in a portal, and each employee signs in with their own GitHub account. The agent then reads and writes issues, pull requests and files as that person, with that person's repository access. You can run the sign-in through your own GitHub OAuth app and block write tools so the connection is read-only.

**What you'll learn**

* How an admin publishes GitHub and how an employee connects
* Which sign-in methods and scopes the integration offers
* How to use your own OAuth app and make the connection read-only

**Before you start**

* A [portal](https://metorial.com/docs/platform/workforce/portals) with at least one access group
* A GitHub account for each person who will connect
* To use your own OAuth app: permission to create an OAuth app in your GitHub organization

## Sign-in methods

| Method                                 | Type  | Use it when                                                                  |
| -------------------------------------- | ----- | ---------------------------------------------------------------------------- |
| **GitHub.com**                         | OAuth | People sign in at github.com. This is the default.                           |
| **Enterprise**                         | OAuth | You run GitHub Enterprise Server. Setup asks for your GitHub Enterprise URL. |
| **Personal Access Token (GitHub.com)** | Token | You want a classic or fine-grained token instead of OAuth.                   |
| **Personal Access Token (Enterprise)** | Token | The same, for GitHub Enterprise Server.                                      |

## Admin: publish GitHub in a portal

### In the dashboard

#### 1. Open Shared Resources

Open **Workforce**, choose the portal, and select **Shared Resources** under **Access**.

#### 2. Share a new integration

Select **Share a Resource**, then **New Integration**, and choose GitHub. Under **Auth Method**, keep **GitHub.com**. For how members connect, choose **Each person connects**, so every employee uses their own GitHub account.

#### 3. Choose who gets it

Add the access groups that should see GitHub. When a person asks for access from the portal, the request appears under **Access Requests**.

### With the CLI

The CLI cannot create the per-user GitHub integration. Once it exists, you can check which groups have it:

```bash
metorial-admin portals access list <portal-id> --type provider_template --search github
```

## Employee: connect your GitHub account

### In the portal

#### 1. Open GitHub in the catalog

Sign in to your portal and open GitHub. The status reads **Available**.

#### 2. Authenticate

Under **Quick setup**, select **Authenticate**. A GitHub tab opens. Sign in and approve the permissions listed.

#### 3. Confirm

Back in the portal, the status changes to **Configured**, and the **Setups** tab shows your connection. If the status later reads **Needs reconnect**, select **Reconnect** and sign in again.

### With the CLI

```bash
metorial catalog search github
metorial setup <catalog-item-id>
```

To connect with a token instead of OAuth, find the method's ID with `metorial catalog get <catalog-item-id>` and pass it as `--auth-method <auth-method-id>`. See [Connect an app from the terminal](https://metorial.com/docs/platform/cli/connect-an-app).

## Scopes

The OAuth methods use GitHub's classic OAuth scopes. The integration can request these:

`repo`, `repo:status`, `public_repo`, `read:org`, `write:org`, `admin:org`, `admin:repo_hook`, `admin:org_hook`, `user`, `user:email`, `gist`, `notifications`, `workflow`, `read:packages`, `write:packages`, `delete:packages`, `project`, `read:project`, `delete_repo`, `security_events`, `read:audit_log`

You narrow the list when you create your own auth credentials. The **Scopes** picker groups them into **Read-Only Scopes**, **Write/Custom Scopes** and **Dangerous Scopes**, and you can allow or reject each group or pick single scopes.

GitHub's `repo` scope covers both reading and writing private repositories. There is no read-only version of it for OAuth apps. To get read-only access to private repositories, either block the write tools (below) or have people connect with a fine-grained personal access token that only has read permissions.

## Use your own GitHub OAuth app

With your own OAuth app, the consent screen shows your company's name, and your GitHub organization owns the app and its approvals.

### 1. Start the credentials in Metorial

In the dashboard, select **Settings**, then **Organization Settings**. Under **Integrations and MCP**, select **Provider Auth**, then **Create Auth Credentials**. Choose GitHub and copy the **Redirect URI**.

### 2. Create the OAuth app in GitHub

In GitHub, click your profile picture, then **Settings**, then **Developer settings**, then **OAuth apps**, and click **New OAuth App**. Enter an **Application name** and a **Homepage URL**. Paste the redirect URI from Metorial into **Authorization callback URL**. Click **Register application**. GitHub also lets you register the app under an organization you administer. GitHub's steps are in [Creating an OAuth app](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app).

### 3. Finish in Metorial

Copy the client ID from the app's page in GitHub and create a client secret there. Back in Metorial, enter a **Name**, the **Client ID** and the **Client Secret**, review **Scopes**, and select **Create**. Then pick these credentials for the GitHub integration.

## Make the connection read-only

Open the integration's **Tool Filters** and set the write and destructive tool groups to **Reject**. Read tools such as `get_issue`, `list_pull_requests` and `search` stay available, and tools such as `merge_pull_request` and `manage_file_content` are no longer offered to any agent. Employees see the result on the integration's page in the portal under **Tool access**. For the full walkthrough, see [Tool permissions](https://metorial.com/docs/platform/guides/tool-permissions).

## Check it worked

```bash
metorial list github
metorial tools <integration-id>
metorial call <integration-id> get_user
```

`get_user` with no input returns the profile of the GitHub account you connected. If you blocked write tools, they are missing from the `tools` list.

## Next steps

* [Create custom OAuth credentials](https://metorial.com/docs/platform/integrations/create-custom-oauth-credentials)
* [Per-user OAuth](https://metorial.com/docs/platform/guides/per-user-oauth)
* [Call a tool from the terminal](https://metorial.com/docs/platform/cli/call-a-tool)
* [Grant Workforce access](https://metorial.com/docs/platform/workforce/grant-access)