> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/g/github-codes.md).

# Github Codes

GitHub Codes reads the repositories of the organizations your token belongs to. For each repository it collects branches, contributors, languages, open pull requests and issues, and the last commit. The result appears in the Source Code inventory.

## Use cases

* List all repositories in your GitHub organizations.

```
Adapters = github-codes
```

* Find repositories that are publicly visible.

```
Adapters = github-codes AND Visibility = public
```

* Find archived repositories that can be reviewed for clean-up.

```
Adapters = github-codes AND IsArchived = true
```

## Before you begin

### Network

| Source              | Destination      | Port | Protocol |
| ------------------- | ---------------- | ---- | -------- |
| OctoXLabs connector | `api.github.com` | 443  | HTTPS    |

### Required permissions

| Scope or role                        | Permission | Needed for                          |
| ------------------------------------ | ---------- | ----------------------------------- |
| Repository permission: Metadata      | Read       | Repository list and details         |
| Repository permission: Contents      | Read       | Files and dependency file content   |
| Repository permission: Pull requests | Read       | Open pull request count             |
| Repository permission: Issues        | Read       | Open issue count                    |
| Organization permission: Members     | Read       | Organization membership and members |

If your organization requires approval for fine-grained personal access tokens, an owner must approve the token.

## Create credentials in GitHub

{% stepper %}
{% step %}

### Start a fine-grained token

In GitHub, go to **Settings** > **Developer settings** > **Personal access tokens** > **Fine-grained tokens** and click **Generate new token**.
{% endstep %}

{% step %}

### Choose the resource owner and repositories

Choose your organization. Give repository access to **All repositories** or select specific repositories.
{% endstep %}

{% step %}

### Set permissions

Set these repository permissions to **Read**: Metadata, Contents, Pull requests, Issues. Set the organization permission **Members** to **Read**.
{% endstep %}

{% step %}

### Get approval and save the token

If the organization requires approval for fine-grained tokens, an owner must approve it. Generate the token and save it.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter             | Required | Type             | Default | Description                                                       |
| --------------------- | -------- | ---------------- | ------- | ----------------------------------------------------------------- |
| Personal access token | Yes      | Text (sensitive) | None    | The token created above.                                          |
| Thread count          | No       | Integer          | 32      | Parallel threads. Minimum 1, maximum 32. Advanced.                |
| Sleep time            | No       | Integer          | 0       | Seconds between thread batches. Increase it on rate limit errors. |

## Troubleshooting

| Error message | Cause                                        | Fix                                                                                                                                                  |
| ------------- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| Not verified  | The code has no adapter-specific error text. | Check the log for `Status Code`, `URL` and `Method` lines. An HTTP 403 usually means a missing token permission or an unapproved fine-grained token. |

## Change history
